コード例 #1
0
 void HandleAddressed(string channel, string nick, string[] message)
 {
     if (!MarkovTools.FoulPlay(message, conf.MaxConsecutive, conf.MaxTotal))
     {
         EmitSentence(channel, message, nick);
         AbsorbSentence(channel, nick, message);
     }
     else
     {
         irc.SendMessage(channel, "Foul play detected! Stop trying to teach me stupid things, {0}", nick);
     }
 }
コード例 #2
0
ファイル: RandomChoice.cs プロジェクト: IvionSauce/MeidoBot
    void Countdown(string target, int seconds)
    {
        const string stdLaunch = "Liftoff!";
        string       launch    = RandomChoice.ChooseRndItem(conf.LaunchChoices) ?? stdLaunch;

        irc.SendMessage(target, "Commencing Countdown");
        Thread.Sleep(500);
        for (int tminus = seconds; tminus > 0; tminus--)
        {
            irc.SendMessage(target, tminus.ToString());
            Thread.Sleep(1000);
        }
        irc.SendMessage(target, launch);
    }
コード例 #3
0
 void PrintResults(SearchResults results, Site site, string target)
 {
     foreach (var msg in site.ProcessResults(results))
     {
         irc.SendMessage(target, msg);
     }
 }
コード例 #4
0
ファイル: Sed.cs プロジェクト: IvionSauce/MeidoBot
    void Replace(ReplaceAction replace, string channel, string invoker)
    {
        foreach (var item in history.GetMessages(channel))
        {
            string replacedMsg;
            switch (replace.TryReplace(item.Message, out replacedMsg))
            {
            case ReplaceResult.NoMatch:
                continue;

            case ReplaceResult.RegexTimeout:
                irc.SendNotice(invoker, "Your regular expression timed out.");
                return;

            case ReplaceResult.Success:
                if (FoulPlay(replacedMsg))
                {
                    irc.SendNotice(invoker, "Replaced message was too long, not outputting to prevent spam.");
                }
                else
                {
                    irc.SendMessage(channel, "<{0}> {1}", item.Nick, replacedMsg);
                }
                return;
            } // switch
        }     // foreach
    }
コード例 #5
0
ファイル: MiscUtils.cs プロジェクト: IvionSauce/MeidoBot
 bool Say(string channel, string message)
 {
     if (InChannel(channel))
     {
         irc.SendMessage(channel, message);
         return(true);
     }
     return(false);
 }
コード例 #6
0
    void ReadFeed(object data)
    {
        var feed = OpenFeed();

        if (feed != null)
        {
            SanitizeLastPrinted();
            // Assign it a value, else the C# compiler thinks it will be unassigned once the loop exits. Which is a
            // possibility, since feed.Items could be empty...
            DateTimeOffset latestPublish = DateTimeOffset.MinValue;
            // So let's track that (it's also nice for logging).
            int itemsSeen = 0;
            foreach (SyndicationItem item in feed.Items)
            {
                // Save the most recent publishing date for later.
                if (itemsSeen == 0)
                {
                    latestPublish = item.PublishDate;
                }

                itemsSeen++;
                // Once we hit items that we probably already have printed, stop processing the rest.
                if (item.PublishDate <= lastPrintedTime)
                {
                    break;
                }
                // Skip processing items in categories we don't care about.
                if (Skip(item, conf.SkipCategories))
                {
                    continue;
                }

                string[] channels = patterns.PatternMatch(item.Title.Text);
                foreach (string channel in channels)
                {
                    irc.SendMessage(channel, "号外! 号外! 号外! \u0002:: {0} ::\u000F {1}", item.Title.Text, item.Id);
                }
            }

            if (itemsSeen > 0)
            {
                log.Verbose("Read {0} item(s) from feed. Most recent publish date is {1:s}",
                            itemsSeen, latestPublish.ToLocalTime());

                lastPrintedTime = latestPublish;
                dtFile.Write(latestPublish);
            }
            else
            {
                log.Error("No items were processed in ReadFeed: RSS/Atom feed had 0 items.");
            }
        }

        Reschedule();
    }
コード例 #7
0
ファイル: TimeLeft.cs プロジェクト: IvionSauce/MeidoBot
    void SendTime(string target, string name, DateTime date)
    {
        TimeSpan timeLeft = date - DateTime.UtcNow;
        string   message;

        if (timeLeft.Days >= 2)
        {
            message = string.Format("Days: {0} :: {1} [{2}]",
                                    timeLeft.Days, name, date.ToString(dateFmt));
        }
        else
        {
            message = string.Format("Hours: {0:0.#} :: {1} [{2}]",
                                    timeLeft.TotalHours, name, date.ToString(dateFmt));
        }

        irc.SendMessage(target, message);
    }
コード例 #8
0
    void OutputUrl(string url)
    {
        var result = WebToIrc.WebInfo(url);

        if (result.Success)
        {
            if (result.PrintTitle)
            {
                irc.SendMessage(Channel, UrlTools.Filter(result.Title));
            }

            log.Message(result.Messages);
            log.Message("{0} -- {1}", result.Requested, result.Title);
        }
        else
        {
            log.Message(ReportError(result));
        }
    }
コード例 #9
0
 void WeatherSearch(ITriggerMsg e, WeatherLocation location)
 {
     if (TryGetConditions(location, out WeatherConditions cond))
     {
         if (cond.Success)
         {
             irc.SendMessage(e.ReturnTo, WeatherFormat.IrcFormat(cond));
         }
         else if (cond.HttpErrorIs(HttpStatusCode.NotFound))
         {
             e.Reply("Sorry, couldn't find anything for query '{0}'.", location);
         }
         else
         {
             e.Reply(cond.Exception.Message);
         }
     }
     else
     {
         e.Reply(weatherError);
     }
 }