Exemple #1
0
        static void TheRussia(BotMessageContext ctx, string data)
        {
            var chan  = ctx.IRC.Channels[ctx.Msg.Source];
            var regex = new Regex(@"\brussia(?:|ns?)\b", RegexOptions.IgnoreCase);

            if (regex.Match(data).Success)
            {
                ctx.IRC.SendMessage($"{Fmt.Colorize(Fmt.Colors.Red)}Russia!{Fmt.Reset}", chan.Name);
            }
        }
Exemple #2
0
        static void HtmlTitles(BotMessageContext ctx, string data)
        {
            var chan    = ctx.IRC.Channels[ctx.Msg.Source];
            var matches = new Regex(@"\b(https?://\S+)\b").Matches(data); // (?:\b|['""])

            foreach (Match match in matches)
            {
                var url = match.Groups[1].Value;
                Utils.GetHtmlTitleAsync(url,
                                        v => ctx.IRC.SendMessage($"Found URL: {Fmt.Colorize(Fmt.Colors.Green)}{v}{Fmt.Reset}", chan.Name));
            }
        }
Exemple #3
0
        static void SendMsg(BotCommandContext ctx, string data)
        {
            var args = Utils.SimpleParse(data);
            var text = string.Join(" ", args.Skip(1)).Trim();
            var msg  = $"<{Fmt.Colorize(Fmt.Colors.Teal)}{ctx.User.Nick}{Fmt.Reset}> {text}";

            switch (args[0])
            {
            case "ALL": {
                var chans = ctx.IRC.Channels.Select(w => w.Name).ToArray();
                ctx.IRC.SendMessage(msg, chans);
                break;
            }

            default: {
                var chans = args[0].Split(',', ' ');
                ctx.IRC.SendMessage(msg, chans);
                break;
            }
            }
        }