Beispiel #1
0
        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));
            };
        }
Beispiel #2
0
Datei: Bot.cs Projekt: binn/Meru
        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);
        }
Beispiel #3
0
        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);
        }