private async void Client_OnMessageReceived(object sender, TwitchLib.Client.Events.OnMessageReceivedArgs e) { try { if (e.ChatMessage.Username == client.TwitchUsername) { return; } CommandMessage command = new CommandMessage(e.ChatMessage.Message, true, $"@{config.BotUsername.ToLower()}"); ChatMessage message = e.ChatMessage; string channelNameL = message.Channel.ToLower(); ChannelConfig channelConfig = config.JoinedChannels.ContainsKey(message.Channel.ToLower()) ? config.JoinedChannels[channelNameL] : new ChannelConfig(); if (channelConfig.MentionOnly && !command.Mentioned) { return; } switch (command.Command.ToLower()) { case "!uptime": { var uptime = GetUptime(message.Channel); client.SendMessage(message.Channel, uptime == null ? $"{message.Channel} is op dit moment niet aan het streamen! lekkerKonkie" : $"{message.Channel} is al {(int)(uptime?.TotalMinutes ?? 0)} minuten aan het streamen"); break; } case "!join": { string channelName = command.ReadString(); if (!string.IsNullOrEmpty(channelName) && !config.JoinedChannels.ContainsKey(channelName.ToLower())) { var channel = api.Users.v5.GetUserByNameAsync(channelName).Result.Matches; if (channel != null && channel.Length >= 1) { config.JoinedChannels.Add(channelName.ToLower(), new ChannelConfig()); client.JoinChannel(channelName); client.SendMessage(message.Channel, $"lekkerRichard ik kom naar het kanaal {channelName} lekkerSicko "); botConfigs.Save(); } } break; } case "lekkerrichard": { if (channelConfig.RichardEmoteEnabled) { client.SendMessage(message.Channel, $"lekkerRichard lekkerRichard lekkerRichard lekkerSicko {k++}"); } break; } case "avond": { if (channelConfig.EveningEnabled && (!botEveningTimeout.ContainsKey(message.UserId) || (DateTime.Now - botEveningTimeout[message.UserId]).TotalMinutes > channelConfig.EveningTimeout)) { botEveningTimeout[message.UserId] = DateTime.Now; client.SendMessage(message.Channel, $"/me Avond @{e.ChatMessage.DisplayName} malse makker! lekkerRichard lekkerDag"); } break; } case "middag": { if (channelConfig.EveningEnabled && !botEveningTimeout.ContainsKey(message.UserId) || (DateTime.Now - botEveningTimeout[message.UserId]).TotalMinutes > channelConfig.EveningTimeout) { botEveningTimeout[message.UserId] = DateTime.Now; client.SendMessage(message.Channel, $"/me Middag @{e.ChatMessage.DisplayName} malse makker! lekkerRichard lekkerDag"); } break; } case "!enable": case "!disable": { if (IsAdmin(message)) { switch (command.ReadString().ToLower()) { case "mention": { channelConfig.MentionOnly = command.Command.ToLower() == "!enable"; SendMessage($"Ik reageer " + (channelConfig.MentionOnly ? $"nu alleen op @{client.TwitchUsername}" : "nu gewoon op alle chat berichten"), message.Channel); break; } case "emote": { channelConfig.RichardEmoteEnabled = command.Command.ToLower() == "!enable"; SendMessage($"Ik reageer " + (channelConfig.RichardEmoteEnabled ? "weer op lekkerRichard lekkerSicko" : "niet meer op lekkerRichard lekkerAppie"), message.Channel); break; } case "evening": case "avond": { channelConfig.EveningEnabled = command.Command.ToLower() == "!enable"; SendMessage($"Ik reageer " + (channelConfig.EveningEnabled ? "weer op 'avond' lekkerRichard" : "niet meer op 'avond' lekkerAppie"), message.Channel); break; } } botConfigs.Save(); } break; } default: { //Need to move stuff around to make this less italian rrly need to if (message.Message.ToLower().Contains(" avond") || message.Message.ToLower().Contains(" avond ")) { goto case "avond"; } else if (message.Message.ToLower().Contains(" middag") || message.Message.ToLower().Contains(" middag ")) { goto case "middag"; } break; } } } catch (Exception ex) { await BotWrapper.DiscordBot.sendDebugMessage(ex.ToString()); } }
private async Task MessageReceived(SocketMessage message) { try { var senderUser = ((global::Discord.WebSocket.SocketGuildUser)message.Author); string sender = senderUser.Nickname; sender = sender == null ? message.Author.Username : sender; CommandMessage command = new CommandMessage(message.Content); var klaas = await message.Channel.GetUserAsync(command.Mention); if (klaas == null || (klaas.Username.ToLower() != DiscordClient.CurrentUser.Username.ToLower())) { return; } switch (command.Command) { case "test": { await message.Channel.SendMessageAsync("test"); break; } case "help": { await message.Channel.SendMessageAsync(@"Jooo malse makker, \n" + "Ik ben er om je te helpen!\n" + "Gebruik '@richard dab' voor een mooie dab.\n " + "Gebruik '@richard kokhals' voor een kokhals.\n " + "Gebruik '@richard meme' voor een leuke meme.\n" + "Gebruik '@richard weer' voor het weer!"); break; } case "connect": { var channelId = message.Channel.Id; var guildId = senderUser.Guild.Id; ChannelInfo channel = new ChannelInfo() { ChannelId = channelId, GuildId = guildId }; config.connectedChannels.Add(channel); botsConfig.Save(); await message.Channel.SendMessageAsync("Channel toegevoegd."); break; } case "message": { if (senderUser.Id != config.AdminId) { await SendMessageToChannels(command.ReadString(true)); } break; } case "meme": case "dab": case "vinger": case "kokhals": { var memeType = MemeTypeHelper.FromString(command.Command); var file = GetMeme(memeType); if (!string.IsNullOrEmpty(file)) { Task.Run(async() => await message.Channel.SendFileAsync(file)); } else { await sendDebugMessage($"image error {command} not found??"); } break; } case "weer": { var weatherMessage = await message.Channel.SendMessageAsync(":robot:"); await weatherMessage.ModifyAsync(x => { x.Content = ""; x.Embed = GetWeather(); }); break; } case "broadcastweer": { if (senderUser.Id != config.AdminId) { var weer = GetWeather(); await SendMessageToChannels(":robot:", weer); } break; } } } catch (Exception e) { await sendDebugMessage(e.ToString()); } }