//Actions à effectuer lors de la connexion au chat void OnJoin(object sender, IrcEventArgs e) { irc.SendMessage(SendType.Message, "#narxhen", "Bienvenue sur le chat"); }
internal static void HandleMessage(object sender, ChannelMessageEventArgs msg) { DialogWindow.AddMessage($"{msg.Channel} => {msg.Badge.DisplayName}: {msg.Message}"); #region DustSection if (BotEntry.RedstoneDust.ContainsKey(msg.From)) { if (msg.Badge.sub) { if (BotEntry.RedstoneDust[msg.From].HasBoost) { } else { BotEntry.RedstoneDust[msg.From].HasBoost = true; } } else { if (BotEntry.RedstoneDust[msg.From].HasBoost && !BotEntry.Channel.Value.Contains("bot")) { BotEntry.RedstoneDust[msg.From].HasBoost = false; } } BotEntry.RedstoneDust[msg.From].Chatter = true; } else { BotEntry.RedstoneDust.Add(msg.From, new Redstone.RedstoneData { Dust = 0, HasBoost = msg.Badge.sub, Chatter = true }); } if (RedstoneDust[msg.From].User == null || RedstoneDust[msg.From].User.Nick == null) { RedstoneDust[msg.From].User = new User(msg); } else { RedstoneDust[msg.From].User._mod = msg.Badge.mod; RedstoneDust[msg.From].User._sub = msg.Badge.sub; } #endregion int argPos = 0; /// Determine if the message is a command, based on if it starts with '!' or a mention prefix if (!(msg.HasCharPrefix('!', ref argPos))) { NonCommandMessage?.Invoke(msg); return; } /// Create a Command Context var context = new CommandContext(msg); /// If user want some help: read a Summary atribute for commands and reply it if (msg.HasStringPrefix("!help", ref argPos)) { if (msg.Message.Substring(argPos).Length >= 1) { var info = commands.Search(context, argPos + 1); if (info.Commands.Count != 0) { { client.SendMessage(msg.Channel, info.Commands[0].Command.Summary); return; } } } else { var text = new List <string> { }; foreach (var it in commands.Commands) { bool pass = false; foreach (var a in it.Attributes) { if (a is HideFromHelpAttribute) { pass = true; } } if (pass) { continue; } if (it.Module.Group != null) { if (!text.Contains($"{it.Module.Group} {it.Name}")) { text.Add($"{it.Module.Group} {it.Name}"); } } else { if (!text.Contains($"{it.Name}")) { text.Add($"{it.Name}"); } } } //if (text.Length > 2) //text.Substring(0, text.Length - 2); //else return; var str = ""; foreach (var cmd in text) { str += $"{cmd}, "; } if (str.Length > 2) { str = str.Substring(0, str.Length - 2) + "."; } else { return; } client.SendMessage(msg.Channel, str + " Используйте !help <команда> для дополнительных сведений"); } } /// Execute the command. (result does not indicate a return value, /// rather an object stating if the command executed successfully) var result = commands.ExecuteAsync(context, argPos, services); if (!result.Result.IsSuccess) { if (result.Result.ErrorReason.Contains("Комманда не найдена")) { NonCommandMessage?.Invoke(msg); return; } client.SendMessage(msg.Channel, result.Result.ErrorReason); Logger.Log(result.Result.ErrorReason); } }