static void Main(string[] args) { var bot = new TelegramBotClient( BotTokenResolver.GetToken(), new QueuedHttpClient(TimeSpan.FromSeconds(1)) ); var botManager = new BotManager(bot); botManager.ConfigureServices((servicesWrap) => { servicesWrap.AddMvc(new MvcOptions() { //Useful for debugging. CheckEqualsRouteInfo = true }); //Logging service example with NLog you can see in IRO.Tests.Telegram. }); botManager.ConfigureBuilder(builder => { builder.UseDevEceptionMessage(); builder.UseOldUpdatesIgnoring(); builder.UseMvc(mvcBuilder => { //Write /debug to see info about routing. mvcBuilder.UseDebugInfo(); mvcBuilder.MapRouteAction( async(actionCtx) => { await actionCtx.UpdateContext.SendTextMessageAsync("Bot commands works."); }, template: "/help" ); }); }); //Default implemention use standart ITelegramBotClient polling. //You can add webhooks implemention using Telegram.Bot.AspNetPipeline.WebhookSupport or //write your own IUpdatesReceiver. botManager.Setup(); botManager.Start(); Console.WriteLine("Bot initialized."); while (true) { Console.ReadLine(); } botManager.Dispose(); }
public virtual void Dispose() { if (_twitchNETBotManager != null) { _twitchNETBotManager.Dispose(); _twitchNETBotManager.ConnectionBotEvent -= OnConnectionBotEvent; _twitchNETBotManager.ConnectionServerBotEvent -= OnConnectionServerBotEvent; _twitchNETBotManager.ConnectionServerUserEvent -= OnConnectionServerUserEvent; _twitchNETBotManager.MessageServerChatEvent -= OnMessageServerChatEvent; _twitchNETBotManager.MessageServerCommandEvent -= OnMessageServerCommandEvent; _twitchNETBotManager.MessageWhisperEvent -= OnMessageWhisperEvent; _twitchNETBotManager.ColorChangeEvent -= OnColorChangeEvent; _twitchNETBotManager.ErrorEvent -= OnErrorEvent; } }
private void MainWindow_FormClosed(object sender, FormClosedEventArgs e) { Thread shutdownThread = new Thread(new ThreadStart(() => { try { botManager.Dispose(); } catch (Exception) { } })); shutdownThread.Start(); ShuttingDownDialog dialog = new ShuttingDownDialog(shutdownThread); dialog.ShowDialog(); dialog.BringToFront(); }
public void Dispose() { _botInstance?.Dispose(); }