Updating examples
This commit is contained in:
parent
5d2f3e7fe9
commit
82e6d79ec4
50
README.md
50
README.md
@ -106,6 +106,7 @@ var bot = BotBaseBuilder
|
||||
})
|
||||
.NoSerialization()
|
||||
.UseEnglish()
|
||||
.UseSingleThread()
|
||||
.Build();
|
||||
|
||||
// Upload bot commands to BotFather
|
||||
@ -126,8 +127,32 @@ like ChatId and other stuff your carrying.
|
||||
From there you build up your bots:
|
||||
|
||||
```csharp
|
||||
public class StartForm : FormBase
|
||||
public class Start : FormBase
|
||||
{
|
||||
|
||||
public Start()
|
||||
{
|
||||
//Additional event handlers
|
||||
Init += Start_Init;
|
||||
Opened += Start_Opened;
|
||||
Closed += Start_Closed;
|
||||
}
|
||||
|
||||
// Gets invoked on initialization, before navigation
|
||||
private async Task Start_Init(object sender, Args.InitEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Gets invoked after opened
|
||||
private async Task Start_Opened(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Gets invoked after form has been closed
|
||||
private async Task Start_Closed(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Gets invoked during Navigation to this form
|
||||
public override async Task PreLoad(MessageResult message)
|
||||
{
|
||||
@ -224,6 +249,7 @@ var bot = BotBaseBuilder
|
||||
})
|
||||
.NoSerialization()
|
||||
.UseEnglish()
|
||||
.UseSingleThread()
|
||||
.Build();
|
||||
|
||||
bot.BotCommand += async (s, en) =>
|
||||
@ -264,15 +290,15 @@ public class SimpleForm : AutoCleanForm
|
||||
{
|
||||
public SimpleForm()
|
||||
{
|
||||
this.DeleteSide = TelegramBotBase.Enums.eDeleteSide.Both;
|
||||
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
|
||||
DeleteSide = EDeleteSide.Both;
|
||||
DeleteMode = EDeleteMode.OnLeavingForm;
|
||||
|
||||
this.Opened += SimpleForm_Opened;
|
||||
Opened += SimpleForm_Opened;
|
||||
}
|
||||
|
||||
private async Task SimpleForm_Opened(object sender, EventArgs e)
|
||||
{
|
||||
await this.Device.Send("Hello world! (send 'back' to get back to Start)\r\nOr\r\nhi, hello, maybe, bye and ciao");
|
||||
await Device.Send("Hello world! (send 'back' to get back to Start)\r\nOr\r\nhi, hello, maybe, bye and ciao");
|
||||
}
|
||||
|
||||
public override async Task Load(MessageResult message)
|
||||
@ -310,7 +336,13 @@ public class SimpleForm : AutoCleanForm
|
||||
```csharp
|
||||
public class ButtonTestForm : AutoCleanForm
|
||||
{
|
||||
public override async Task Opened()
|
||||
public ButtonTestForm()
|
||||
{
|
||||
this.DeleteMode = eDeleteMode.OnLeavingForm;
|
||||
Opened += ButtonTestForm_Opened;
|
||||
}
|
||||
|
||||
private async Task ButtonTestForm_Opened(object sender, EventArgs e)
|
||||
{
|
||||
await this.Device.Send("Hello world! (Click 'back' to get back to Start)");
|
||||
}
|
||||
@ -380,9 +412,10 @@ public class ProgressTest : AutoCleanForm
|
||||
public ProgressTest()
|
||||
{
|
||||
this.DeleteMode = eDeleteMode.OnLeavingForm;
|
||||
Opened += ProgressTest_Opened;
|
||||
}
|
||||
|
||||
public override async Task Opened()
|
||||
private async Task ProgressTest_Opened(object sender, EventArgs e)
|
||||
{
|
||||
await this.Device.Send("Welcome to ProgressTest");
|
||||
}
|
||||
@ -862,6 +895,7 @@ var bot = BotBaseBuilder
|
||||
})
|
||||
.UseSimpleJSON(AppContext.BaseDirectory + "config\\states.json")
|
||||
.UseEnglish()
|
||||
.UseSingleThread()
|
||||
.Build();
|
||||
|
||||
await bot.Start();
|
||||
@ -885,6 +919,7 @@ var bot = BotBaseBuilder
|
||||
})
|
||||
.UseJSON(AppContext.BaseDirectory + "config\\states.json")
|
||||
.UseEnglish()
|
||||
.UseSingleThread()
|
||||
.Build();
|
||||
|
||||
await bot.Start();
|
||||
@ -907,6 +942,7 @@ var bot = BotBaseBuilder
|
||||
})
|
||||
.UseXML(AppContext.BaseDirectory + "config\\states.xml")
|
||||
.UseEnglish()
|
||||
.UseSingleThread()
|
||||
.Build();
|
||||
|
||||
await bot.Start();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user