/// <summary> /// Proccessor :) /// </summary> /// <param name="iupdate">iupdate class that is target.</param> /// <param name="Client">sender of update</param> /// <param name="update">Update itself</param> /// <param name="CustomData">Custom data</param> public Proccessor(iUpdate iupdate, TelegramBotClient Client, Update update, Dictionary <string, object> customData) { this.iupdate = iupdate; client = Client; newupdate = update; CD = customData; }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects). } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. CD = null; client = null; newupdate = null; iupdate = null; disposedValue = true; } }
private static async void On_Update(object sender, Telegram.Bot.Args.UpdateEventArgs e) { var Client = (TelegramBotClient)sender; iUpdate finder = null; var customdata = new Dictionary <string, object>(); switch (e.Update.Type) { case UpdateType.Message: { finder = TBH.Variables.UpdatesList .Where(x => x.Trigger.UpdateType == UpdateType.Message) .FirstOrDefault(x => x.Trigger.TextTriggers.Any(c => c == e.Update.Message.Text.ToLower())); customdata.Add("LangCode", e.Update.Message.From.LanguageCode); break; } case UpdateType.CallbackQuery: { finder = TBH.Variables.UpdatesList .Where(x => x.Trigger.UpdateType == UpdateType.CallbackQuery) .FirstOrDefault(x => e.Update.CallbackQuery.Data.StartsWith(x.Trigger.TextTriggers[0])); customdata.Add("LangCode", e.Update.CallbackQuery.From.LanguageCode); break; } default: break; } using (Proccessor proccessor = new Proccessor(finder, Client, e.Update, customdata)) { if (finder is null) { return; } await proccessor.Proccess().ConfigureAwait(false); } }