public DiscordBotClient(DiscordProviderConfigurations config) { client.MessageReceived += async(msg) => { await OnMessageReceive.Invoke(new DiscordMessageObject(msg)); }; client.MessageUpdated += async(msgCached, newMsg, channel) => { await OnMessageEdit.Invoke(new DiscordMessageObject(newMsg), new DiscordChannelObject(channel)); }; }
public void AddProvider(IBotProvider provider) { provider.OnMessageReceive += async(m) => { await OnMessageReceive.Invoke(m); }; provider.OnMessageEdit += async(m) => { await OnMessageEdit.Invoke(m); }; provider.OnMessageDelete += async(m) => { await OnMessageDelete.Invoke(m); }; providers.Add(provider); }
private static Task HandleUpdates(ITelegramBotClient botClient, Update update, CancellationToken cancellationToken) { switch (update.Type) { case UpdateType.Message: OnMessage?.Invoke(api, new MessageEventArgs(update.Message)); break; case UpdateType.EditedMessage: OnMessageEdit?.Invoke(api, new MessageEditEventArgs(update.EditedMessage)); break; case UpdateType.CallbackQuery: OnCallback?.Invoke(api, new CallbackQueryEventArgs(update.CallbackQuery)); break; } return(Task.CompletedTask); }