1+ using Deployf . Botf ;
2+
3+ BotfProgram . StartBot ( args ) ;
4+
5+ class ActionAndQueryController : BotController
6+ {
7+ [ Action ( "/start" , "start the bot" ) ]
8+ public void Start ( )
9+ {
10+ PushL ( $ "Hello!") ;
11+ Push ( "This an example of how to use Q(...) and action's parameters" ) ;
12+
13+ RowButton ( "Simple action" , Q ( ActionWithNoArgs ) ) ;
14+ RowButton ( "Action with primitive args" , Q ( ActionWithPrimitiveArgs , 10 , "hi" ) ) ;
15+
16+ var instance = new ExampleClass
17+ {
18+ IntField = 25 ,
19+ StringProp = "very looooong string with many words"
20+ } ;
21+ RowButton ( "Action with class" , Q ( ActionWithStoredValue , instance ) ) ;
22+ }
23+
24+ [ Action ]
25+ void ActionWithNoArgs ( )
26+ {
27+ Push ( "Just action :)" ) ;
28+
29+ RowButton ( "Back" , Q ( Start ) ) ;
30+ RowButton ( "Back(manually)" , "/start" ) ;
31+ }
32+
33+ [ Action ]
34+ void ActionWithPrimitiveArgs ( int arg1 , string arg2 )
35+ {
36+ PushL ( "Action with primitive arguments" ) ;
37+ PushL ( $ "Arg1: { arg1 } ") ;
38+ PushL ( $ "Arg2: { arg2 } ") ;
39+
40+ RowButton ( "Back" , Q ( Start ) ) ;
41+ }
42+
43+ [ Action ]
44+ void ActionWithStoredValue ( ExampleClass instance )
45+ {
46+ PushL ( "Action with class as a parameter" ) ;
47+ PushL ( $ "IntField: { instance . IntField } ") ;
48+ PushL ( $ "StringProp: { instance . StringProp } ") ;
49+
50+ instance . IntField += 1 ;
51+ var action = Q ( ActionWithStoredValue , instance ) ;
52+ RowButton ( "IntField += 1" , action ) ;
53+
54+ RowButton ( "Back" , Q ( Start ) ) ;
55+ }
56+ }
57+
58+ class ExampleClass
59+ {
60+ public int IntField ;
61+ public string StringProp { get ; set ; }
62+ }
0 commit comments