diff --git a/TelegramBotBase/BotBase.cs b/TelegramBotBase/BotBase.cs index 3441673..bfeeb1e 100644 --- a/TelegramBotBase/BotBase.cs +++ b/TelegramBotBase/BotBase.cs @@ -206,211 +206,6 @@ namespace TelegramBotBase - //private async void Client_Message(object sender, MessageResult e) - //{ - // if (this.GetSetting(eSettings.SkipAllMessages, false)) - // return; - - // try - // { - // DeviceSession ds = this.Sessions.GetSession(e.DeviceId); - // e.Device = ds; - - // if (this.GetSetting(eSettings.LogAllMessages, false)) - // { - // OnMessage(new MessageIncomeEventArgs(e.DeviceId, ds, e)); - // } - - // ds?.OnMessageReceived(new MessageReceivedEventArgs(e.Message)); - - // await Client_Loop(sender, e); - // } - // catch (Telegram.Bot.Exceptions.ApiRequestException ex) - // { - - // } - // catch (Exception ex) - // { - // DeviceSession ds = this.Sessions.GetSession(e.DeviceId); - // OnException(new SystemExceptionEventArgs(e.Message.Text, ds?.DeviceId ?? -1, ds, ex)); - // } - //} - - - - //private async Task Client_TryMessage(object sender, MessageResult e) - //{ - // DeviceSession ds = e.Device; - // if (ds == null) - // { - // ds = await this.Sessions.StartSession(e.DeviceId); - // e.Device = ds; - - // ds.LastMessage = e.Message; - - // OnSessionBegins(new SessionBeginEventArgs(e.DeviceId, ds)); - // } - - // ds.LastAction = DateTime.Now; - // ds.LastMessage = e.Message; - - // //Is this a bot command ? - // if (e.IsBotCommand && this.BotCommands.Count(a => "/" + a.Command == e.BotCommand) > 0) - // { - // var sce = new BotCommandEventArgs(e.BotCommand, e.BotCommandParameters, e.Message, ds.DeviceId, ds); - // await OnBotCommand(sce); - - // if (sce.Handled) - // return; - // } - - // FormBase activeForm = null; - - // int i = 0; - - // //Should formulars get navigated (allow maximum of 10, to dont get loops) - // do - // { - // i++; - - // //Reset navigation - // ds.FormSwitched = false; - - // activeForm = ds.ActiveForm; - - // //Pre Loading Event - // await activeForm.PreLoad(e); - - // //Send Load event to controls - // await activeForm.LoadControls(e); - - // //Loading Event - // await activeForm.Load(e); - - // //Is Attachment ? (Photo, Audio, Video, Contact, Location, Document) - // if (e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Contact | e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Document | e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Location | - // e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Photo | e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Video | e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Audio) - // { - // await activeForm.SentData(new DataResult(e)); - // } - - // //Render Event - // if (!ds.FormSwitched) - // { - // await activeForm.RenderControls(e); - - // await activeForm.Render(e); - // } - - // e.IsFirstHandler = false; - - // } while (ds.FormSwitched && i < this.GetSetting(eSettings.NavigationMaximum, 10)); - - - //} - - - //private async Task Client_Loop(object sender, MessageResult e) - //{ - // DeviceSession ds = e.Device; - // if (ds == null) - // { - // ds = await this.Sessions.StartSession(e.DeviceId); - // e.Device = ds; - // ds.LastMessage = e.Message; - - // OnSessionBegins(new SessionBeginEventArgs(e.DeviceId, ds)); - // } - - // ds.LastAction = DateTime.Now; - // ds.LastMessage = e.Message; - - // //Is this a bot command ? - // if (e.IsBotCommand && this.BotCommands.Count(a => "/" + a.Command == e.BotCommand) > 0) - // { - // var sce = new BotCommandEventArgs(e.BotCommand, e.BotCommandParameters, e.Message, ds.DeviceId, ds); - // await OnBotCommand(sce); - - // if (sce.Handled) - // return; - // } - - // FormBase activeForm = null; - - // int i = 0; - - // //Should formulars get navigated (allow maximum of 10, to dont get loops) - // do - // { - // i++; - - - - // //Reset navigation - // ds.FormSwitched = false; - - // activeForm = ds.ActiveForm; - - - - // //Pre Loading Event - // await activeForm.PreLoad(e); - - // //Send Load event to controls - // await activeForm.LoadControls(e); - - // //Loading Event - // await activeForm.Load(e); - - // //Is Attachment ? (Photo, Audio, Video, Contact, Location, Document) - // if (e.MessageType == Telegram.Bot.Types.Enums.MessageType.Contact | e.MessageType == Telegram.Bot.Types.Enums.MessageType.Document | e.MessageType == Telegram.Bot.Types.Enums.MessageType.Location | - // e.MessageType == Telegram.Bot.Types.Enums.MessageType.Photo | e.MessageType == Telegram.Bot.Types.Enums.MessageType.Video | e.MessageType == Telegram.Bot.Types.Enums.MessageType.Audio) - // { - // await activeForm.SentData(new DataResult(e)); - // } - - // //Action Event - // if (!ds.FormSwitched && e.IsAction) - // { - // //Send Action event to controls - // await activeForm.ActionControls(e); - - // //Send Action event to form itself - // await activeForm.Action(e); - - // if (!e.Handled) - // { - // var uhc = new UnhandledCallEventArgs(e.Message.Text, e.RawData, ds.DeviceId, e.MessageId, e.Message, ds); - // OnUnhandledCall(uhc); - - // if (uhc.Handled) - // { - // e.Handled = true; - // if (!ds.FormSwitched) - // { - // break; - // } - // } - // } - - // } - - // if (!ds.FormSwitched) - // { - // //Render Event - // await activeForm.RenderControls(e); - - // await activeForm.Render(e); - // } - - // e.IsFirstHandler = false; - - // } while (ds.FormSwitched && i < this.GetSetting(eSettings.NavigationMaximum, 10)); - - - //} - - /// /// This will invoke the full message loop for the device even when no "userevent" like message or action has been raised. /// @@ -445,81 +240,6 @@ namespace TelegramBotBase } - //private async void Client_MessageEdit(object sender, MessageResult e) - //{ - // if (this.GetSetting(eSettings.SkipAllMessages, false)) - // return; - - // try - // { - // DeviceSession ds = this.Sessions.GetSession(e.DeviceId); - // e.Device = ds; - - // if (this.GetSetting(eSettings.LogAllMessages, false)) - // { - // OnMessage(new MessageIncomeEventArgs(e.DeviceId, ds, e)); - // } - - // //Call same, to handle received liked edited - // ds?.OnMessageReceived(new MessageReceivedEventArgs(e.Message)); - - // await Client_TryMessageEdit(sender, e); - // } - // catch (Telegram.Bot.Exceptions.ApiRequestException ex) - // { - - // } - // catch (Exception ex) - // { - // DeviceSession ds = this.Sessions.GetSession(e.DeviceId); - // OnException(new SystemExceptionEventArgs(e.Message.Text, ds?.DeviceId ?? -1, ds, ex)); - // } - //} - - //private async Task Client_TryMessageEdit(object sender, MessageResult e) - //{ - // DeviceSession ds = e.Device; - // if (ds == null) - // { - // ds = await this.Sessions.StartSession(e.DeviceId); - // e.Device = ds; - // } - - // ds.LastAction = DateTime.Now; - // ds.LastMessage = e.Message; - - // //Pre Loading Event - // await ds.ActiveForm.Edited(e); - - // //When form has been switched due navigation within the edit method, reopen Client_Message - // if (ds.FormSwitched) - // { - // await Client_Loop(sender, e); - // } - - //} - - //private async void Client_Action(object sender, MessageResult e) - //{ - // try - // { - // DeviceSession ds = this.Sessions.GetSession(e.DeviceId); - // e.Device = ds; - - // if (this.GetSetting(eSettings.LogAllMessages, false)) - // { - // OnMessage(new MessageIncomeEventArgs(e.DeviceId, ds, e)); - // } - - // await Client_Loop(sender, e); - // } - // catch (Exception ex) - // { - // DeviceSession ds = this.Sessions.GetSession(e.DeviceId); - // OnException(new SystemExceptionEventArgs(e.Message.Text, ds?.DeviceId ?? -1, ds, ex)); - // } - //} - /// /// Will get invoke on an unhandled call. /// @@ -530,81 +250,6 @@ namespace TelegramBotBase OnUnhandledCall(e); } - //private async void Client_TryAction(object sender, MessageResult e) - //{ - // DeviceSession ds = e.Device; - // if (ds == null) - // { - // ds = await this.Sessions.StartSession(e.DeviceId); - // e.Device = ds; - // } - - // ds.LastAction = DateTime.Now; - // ds.LastMessage = e.Message; - - // FormBase activeForm = null; - - // int i = 0; - - // //Should formulars get navigated (allow maximum of 10, to dont get loops) - // do - // { - // i++; - - // //Reset navigation - // ds.FormSwitched = false; - - // activeForm = ds.ActiveForm; - - // //Pre Loading Event - // await activeForm.PreLoad(e); - - // //Send Load event to controls - // await activeForm.LoadControls(e); - - // //Loading Event - // await activeForm.Load(e); - - // //Action Event - // if (!ds.FormSwitched) - // { - // //Send Action event to controls - // await activeForm.ActionControls(e); - - // //Send Action event to form itself - // await activeForm.Action(e); - - // if (!e.Handled) - // { - // var uhc = new UnhandledCallEventArgs(e.Message.Text, e.RawData, ds.DeviceId, e.MessageId, e.Message, ds); - // OnUnhandledCall(uhc); - - // if (uhc.Handled) - // { - // e.Handled = true; - // if (!ds.FormSwitched) - // { - // break; - // } - // } - // } - - // } - - // //Render Event - // if (!ds.FormSwitched) - // { - // await activeForm.RenderControls(e); - - // await activeForm.Render(e); - // } - - // e.IsFirstHandler = false; - - // } while (ds.FormSwitched && i < this.GetSetting(eSettings.NavigationMaximum, 10)); - - //} - /// /// This method will update all local created bot commands to the botfather. ///