Skip to content

Commit 5d2f3e7

Browse files
authored
Merge pull request #67 from MajMcCloud/development
Updating master branch via development branch
2 parents 5cda9e1 + 7aa40b3 commit 5d2f3e7

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

TelegramBotBase/Base/MessageResult.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ void init()
2121
{
2222
IsAction = UpdateData.CallbackQuery != null;
2323

24+
if (Message == null)
25+
return;
26+
2427
IsBotCommand = Message.Entities?.Any(a => a.Type == MessageEntityType.BotCommand) ?? false;
2528

2629
if (!IsBotCommand)

TelegramBotBase/BotBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private async Task Client_MessageLoop(object sender, UpdateResult e)
116116
if (ds == null)
117117
{
118118
ds = await Sessions.StartSession(e.DeviceId);
119-
ds.LastMessage = e.RawData.Message;
119+
ds.LastMessage = e.Message;
120120

121121
OnSessionBegins(new SessionBeginEventArgs(e.DeviceId, ds));
122122
}

TelegramBotBase/Builder/BotBaseBuilder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ public IMessageLoopSelectionStage WithAPIKey(string apiKey)
7373
}
7474

7575

76-
public IBuildingStage QuickStart(string apiKey, Type startForm)
76+
public IBuildingStage QuickStart(string apiKey, Type startForm, bool throwPendingUpdates = false)
7777
{
7878
_apiKey = apiKey;
7979
_factory = new DefaultStartFormFactory(startForm);
8080

8181
DefaultMessageLoop();
8282

83-
NoProxy();
83+
NoProxy(throwPendingUpdates);
8484

8585
OnlyStart();
8686

@@ -94,15 +94,15 @@ public IBuildingStage QuickStart(string apiKey, Type startForm)
9494
}
9595

9696

97-
public IBuildingStage QuickStart<T>(string apiKey)
97+
public IBuildingStage QuickStart<T>(string apiKey, bool throwPendingUpdates = false)
9898
where T : FormBase
9999
{
100100
_apiKey = apiKey;
101101
_factory = new DefaultStartFormFactory(typeof(T));
102102

103103
DefaultMessageLoop();
104104

105-
NoProxy();
105+
NoProxy(throwPendingUpdates);
106106

107107
OnlyStart();
108108

@@ -115,14 +115,14 @@ public IBuildingStage QuickStart<T>(string apiKey)
115115
return this;
116116
}
117117

118-
public IBuildingStage QuickStart(string apiKey, IStartFormFactory startFormFactory)
118+
public IBuildingStage QuickStart(string apiKey, IStartFormFactory startFormFactory, bool throwPendingUpdates = false)
119119
{
120120
_apiKey = apiKey;
121121
_factory = startFormFactory;
122122

123123
DefaultMessageLoop();
124124

125-
NoProxy();
125+
NoProxy(throwPendingUpdates);
126126

127127
OnlyStart();
128128

TelegramBotBase/Builder/Interfaces/IAPIKeySelectionStage.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,26 @@ public interface IAPIKeySelectionStage
2020
/// </summary>
2121
/// <param name="apiKey"></param>
2222
/// <param name="StartForm"></param>
23+
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
2324
/// <returns></returns>
24-
IBuildingStage QuickStart(string apiKey, Type StartForm);
25+
IBuildingStage QuickStart(string apiKey, Type StartForm, bool throwPendingUpdates = false);
2526

2627
/// <summary>
2728
/// Quick and easy way to create a BotBase instance.
2829
/// Uses: DefaultMessageLoop, NoProxy, OnlyStart, NoSerialization, DefaultLanguage
2930
/// </summary>
3031
/// <param name="apiKey"></param>
32+
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
3133
/// <returns></returns>
32-
IBuildingStage QuickStart<T>(string apiKey) where T : FormBase;
34+
IBuildingStage QuickStart<T>(string apiKey , bool throwPendingUpdates = false) where T : FormBase;
3335

3436
/// <summary>
3537
/// Quick and easy way to create a BotBase instance.
3638
/// Uses: DefaultMessageLoop, NoProxy, OnlyStart, NoSerialization, DefaultLanguage
3739
/// </summary>
3840
/// <param name="apiKey"></param>
3941
/// <param name="StartFormFactory"></param>
42+
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
4043
/// <returns></returns>
41-
IBuildingStage QuickStart(string apiKey, IStartFormFactory StartFormFactory);
44+
IBuildingStage QuickStart(string apiKey, IStartFormFactory StartFormFactory, bool throwPendingUpdates = false);
4245
}

0 commit comments

Comments
 (0)