Merge pull request #67 from MajMcCloud/development

Updating master branch via development branch
This commit is contained in:
Florian Zevedei 2024-07-10 14:28:25 +02:00 committed by GitHub
commit 5d2f3e7fe9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 10 deletions

View File

@ -21,6 +21,9 @@ public class MessageResult : ResultBase
{ {
IsAction = UpdateData.CallbackQuery != null; IsAction = UpdateData.CallbackQuery != null;
if (Message == null)
return;
IsBotCommand = Message.Entities?.Any(a => a.Type == MessageEntityType.BotCommand) ?? false; IsBotCommand = Message.Entities?.Any(a => a.Type == MessageEntityType.BotCommand) ?? false;
if (!IsBotCommand) if (!IsBotCommand)

View File

@ -116,7 +116,7 @@ public sealed class BotBase
if (ds == null) if (ds == null)
{ {
ds = await Sessions.StartSession(e.DeviceId); ds = await Sessions.StartSession(e.DeviceId);
ds.LastMessage = e.RawData.Message; ds.LastMessage = e.Message;
OnSessionBegins(new SessionBeginEventArgs(e.DeviceId, ds)); OnSessionBegins(new SessionBeginEventArgs(e.DeviceId, ds));
} }

View File

@ -73,14 +73,14 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
} }
public IBuildingStage QuickStart(string apiKey, Type startForm) public IBuildingStage QuickStart(string apiKey, Type startForm, bool throwPendingUpdates = false)
{ {
_apiKey = apiKey; _apiKey = apiKey;
_factory = new DefaultStartFormFactory(startForm); _factory = new DefaultStartFormFactory(startForm);
DefaultMessageLoop(); DefaultMessageLoop();
NoProxy(); NoProxy(throwPendingUpdates);
OnlyStart(); OnlyStart();
@ -94,7 +94,7 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
} }
public IBuildingStage QuickStart<T>(string apiKey) public IBuildingStage QuickStart<T>(string apiKey, bool throwPendingUpdates = false)
where T : FormBase where T : FormBase
{ {
_apiKey = apiKey; _apiKey = apiKey;
@ -102,7 +102,7 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
DefaultMessageLoop(); DefaultMessageLoop();
NoProxy(); NoProxy(throwPendingUpdates);
OnlyStart(); OnlyStart();
@ -115,14 +115,14 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
return this; return this;
} }
public IBuildingStage QuickStart(string apiKey, IStartFormFactory startFormFactory) public IBuildingStage QuickStart(string apiKey, IStartFormFactory startFormFactory, bool throwPendingUpdates = false)
{ {
_apiKey = apiKey; _apiKey = apiKey;
_factory = startFormFactory; _factory = startFormFactory;
DefaultMessageLoop(); DefaultMessageLoop();
NoProxy(); NoProxy(throwPendingUpdates);
OnlyStart(); OnlyStart();

View File

@ -20,16 +20,18 @@ public interface IAPIKeySelectionStage
/// </summary> /// </summary>
/// <param name="apiKey"></param> /// <param name="apiKey"></param>
/// <param name="StartForm"></param> /// <param name="StartForm"></param>
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
/// <returns></returns> /// <returns></returns>
IBuildingStage QuickStart(string apiKey, Type StartForm); IBuildingStage QuickStart(string apiKey, Type StartForm, bool throwPendingUpdates = false);
/// <summary> /// <summary>
/// Quick and easy way to create a BotBase instance. /// Quick and easy way to create a BotBase instance.
/// Uses: DefaultMessageLoop, NoProxy, OnlyStart, NoSerialization, DefaultLanguage /// Uses: DefaultMessageLoop, NoProxy, OnlyStart, NoSerialization, DefaultLanguage
/// </summary> /// </summary>
/// <param name="apiKey"></param> /// <param name="apiKey"></param>
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
/// <returns></returns> /// <returns></returns>
IBuildingStage QuickStart<T>(string apiKey) where T : FormBase; IBuildingStage QuickStart<T>(string apiKey , bool throwPendingUpdates = false) where T : FormBase;
/// <summary> /// <summary>
/// Quick and easy way to create a BotBase instance. /// Quick and easy way to create a BotBase instance.
@ -37,6 +39,7 @@ public interface IAPIKeySelectionStage
/// </summary> /// </summary>
/// <param name="apiKey"></param> /// <param name="apiKey"></param>
/// <param name="StartFormFactory"></param> /// <param name="StartFormFactory"></param>
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
/// <returns></returns> /// <returns></returns>
IBuildingStage QuickStart(string apiKey, IStartFormFactory StartFormFactory); IBuildingStage QuickStart(string apiKey, IStartFormFactory StartFormFactory, bool throwPendingUpdates = false);
} }