public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
 {
     Match output = Regex.Match(message.Body, @"^!urban (.*)", RegexOptions.IgnoreCase);
     if (output.Success) {
         String queryString = output.Groups[1].Value;
         if (!dict.verify_key(KEY)) {
             log.Error("Invalid key used for dictionary lookup.");
             message.Chat.SendMessage("The automated Urban Dictionary lookup is down until further notice.");
         }
         else {
             log.Debug("Key verified.");
             Definition[] defs = dict.lookup(KEY, queryString);
             if (defs.Length <= 0)
                 message.Chat.SendMessage(String.Format(@"UrbanDictionary lookup of ""{0}"": No results found.", queryString));
             else {
                 message.Chat.SendMessage(String.Format(
                     "UrbanDictionary lookup of \"{0}\":\n\n{1}: {2}\n\n{3}",
                     queryString,
                     defs[0].word,
                     defs[0].definition,
                     defs[0].example
                 ));
             }
         }
     }
 }
 private static void _OnMessageReceived(ChatMessage pMessage, TChatMessageStatus status)
 {
     if ((status == TChatMessageStatus.cmsReceived || status == TChatMessageStatus.cmsSent) && pMessage.ChatName.IndexOf(_SkypeChatUniqueCode) >= 0)
     {
         SlackSender.SendMessage("*" + (String.IsNullOrEmpty(pMessage.Sender.DisplayName) ? _BotSkypeName : pMessage.Sender.DisplayName) + "* : " + pMessage.Body);
     }
 }
Esempio n. 3
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!twitter (.+)", RegexOptions.IgnoreCase);
            if (output.Success) {
                log.Debug("It's my turn!");
                String query = output.Groups[1].Value;

                log.Debug(String.Format("Fetching tweets for {0}.", query));
                var tweets = FluentTwitter.CreateRequest()
                                          .Statuses()
                                          .OnUserTimeline()
                                          .For(query)
                                          .Request()
                                          .AsStatuses();
                log.Debug("Tweets fetched.");

                if (tweets == null || tweets.Count() == 0) {
                    message.Chat.SendMessage(
                        String.Format("I don't think \"{0}\" is a Twitter username.", query)
                    );
                } else {
                    var tweet = tweets.First();

                    message.Chat.SendMessage(
                        String.Format("{0} ({1})", tweet.Text, tweet.CreatedDate.ToRelativeTime(false))
                    );
                }
            }
        }
Esempio n. 4
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            MatchCollection outputColl = Regex.Matches(message.Body, 
                "p(e+)nis|c(o+)ck|d(o+)ng|clitoris|d(i+)ck|sc?(h+)l(o+)ng|p(e+)cker|j(o+)hns(o+)n|w(a+)ng|"
              + "b(o+)ner|one eyed m(o+)nster|phal(l+)[uo]s|pr(i+)ck|winki(e+)|r(i+)ch(a+)rd|will(y|i+e)|j(o+)ystick"
              + "lightning r(o+)d|st(i+)ck ?sh(i+)ft",
                RegexOptions.IgnoreCase);
            if (outputColl.Count > 0) {
                String outputString = "";

                foreach (Match output in outputColl) {
                    String midPart = "";
                    foreach (System.Text.RegularExpressions.Group g in output.Groups) {
                        if (g != output.Groups[0])
                            midPart += g.Value;
                    }

                    midPart = Regex.Replace(midPart, ".", "=");

                    outputString += (outputString == "" ? "" : " ") +
                                    "8==" +
                                    midPart +
                                    "D";
                }
                message.Chat.SendMessage(outputString);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// The skype on message status.
 /// </summary>
 /// <param name="chatMessage">
 /// The chat message.
 /// </param>
 /// <param name="status">
 /// The status.
 /// </param>
 private void SkypeOnMessageStatus(ChatMessage chatMessage, TChatMessageStatus status)
 {
     if (chatMessage.Body.StartsWith("!mail"))
     {
         chatMessage.Chat.SendMessage("mailer called.");
     }
 }
Esempio n. 6
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!waffle", RegexOptions.IgnoreCase);
            if (output.Success) {
                WebRequest webReq = WebRequest.Create("http://waffleimages.com/random");
                webReq.Timeout = 10000;
                log.Info("Contacting server...");
                WebResponse response = webReq.GetResponse();
                log.Debug("Response received; parsing...");
                String responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();

                Match imgFinder = Regex.Match(responseText, @"http://img.waffleimages.com/[0-9a-f]+/r");

                if (!imgFinder.Success) {
                    log.Warn("Couldn't find any image in the result.");
                    log.Warn("If this event s");
                    message.Chat.SendMessage(@"Error communicating with server.");
                }
                else {
                    log.Debug("Result sent to chat.");
                    message.Chat.SendMessage(String.Format(@"Random WaffleImage: {0}", imgFinder.Value));
                }

            }
        }
Esempio n. 7
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"^!(high|)roll (\d+)d(\d+)(([+-])(\d+))?", RegexOptions.IgnoreCase);
            if (output.Success) {
                bool high = output.Groups[1].Value.Length > 0;

                int num = Math.Max(1, Math.Min(200, Convert.ToInt32(output.Groups[2].Value)));
                int size = Math.Max(1, Math.Min(1000000, Convert.ToInt32(output.Groups[3].Value)));

                String pm = "+";
                int mod = 0;
                if (output.Groups[4].Length > 0) {
                    pm = output.Groups[5].Value;
                    mod = Math.Max(0, Math.Min(1000000, Convert.ToInt32(output.Groups[6].Value)));
                }
                
                string roll = String.Format("{0}d{1}{2}", num, size, mod > 0 ? pm + mod : "");

                if (high) {
                    if (!PluginSettings.Default.RollScores.ContainsKey(roll)) {
                        log.Debug(String.Format("Miss for {0}.", roll));
                        message.Chat.SendMessage(String.Format("{0} has never been rolled in this chat.", roll));        
                    } else {
                        log.Debug(String.Format("Hit for {0}.", roll));
                        Roll r =  PluginSettings.Default.RollScores[roll];
                        message.Chat.SendMessage(String.Format(
                            @"{0} rolled {1} on a {2} on {3}.",
                            r.Username,
                            r.Value,
                            roll,
                            r.Time.ToString("MMMM dd, yyyy", new CultureInfo("en-US"))
                        ));
                    }
                } else {
                    int[] vals = new int[num];
                    for (int i = 0; i < num; i++)
                        vals[i] = random.Next(size) + 1;

                    int value = vals.Sum() + (pm == "+" ? 1 : -1) * mod;
                    bool highscore = false;
                    if (!PluginSettings.Default.RollScores.ContainsKey(roll) ||
                         PluginSettings.Default.RollScores[roll].Value < value) {
                        log.Info(String.Format("New high-roll for {0} on chat {1} by {3}: {2}",
                                 roll, message.Chat.Name, value, message.Sender.Handle));
                        Roll r = new Roll(value, message.Sender.Handle, message.Chat.Name, message.Timestamp);
                        PluginSettings.Default.RollScores[roll] = r;
                        PluginSettings.Default.Save();
                        highscore = true;
                    }


                    message.Chat.SendMessage(String.Format(
                        @"{0} rolled; result: {1} ({2}){3}",
                        roll,
                        value,
                        String.Join(", ", Array.ConvertAll<int, String>(vals, new Converter<int, string>(Convert.ToString))),
                        highscore ? " - new high!" : ""
                    ));
                }
            }
        }
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"^!urban (.*)", RegexOptions.IgnoreCase);
            if (output.Success) {
                String query = output.Groups[1].Value;
                
                WebRequest req = (HttpWebRequest) HttpWebRequest.Create("http://api.urbandictionary.com/v0/define?page=1&term=" + System.Uri.EscapeDataString(query));
                WebResponse resp;
                try {
                    resp = req.GetResponse();
                } catch (WebException) {
                    log.Warn("UrbanDictionary appears to be unavailable at the moment.");
                    message.Chat.SendMessage("Sorry, I seem to be unable to contact UrbanDictionary.");
                    return;
                }

                String responseText = new StreamReader(resp.GetResponseStream()).ReadToEnd();
                var defs = (Hashtable) JSON.JsonDecode(responseText);

                if ((string)defs["response_type"] == "no_results") {
                    message.Chat.SendMessage(String.Format(@"UrbanDictionary lookup of ""{0}"": No results found.", query));
                } else {
                    var def = (defs["list"] as ArrayList)[0] as Hashtable;

                    message.Chat.SendMessage(String.Format(
                        "UrbanDictionary lookup of \"{0}\":\n\n{1}: {2}\n\n{3}",
                        query,
                        def["word"],
                        def["definition"],
                        def["example"]
                    ));
                }
            }
        }
Esempio n. 9
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"^!acro ([\w-.]+)", RegexOptions.IgnoreCase);
            if (output.Success) {
                String acronym = output.Groups[1].Value.ToLower();
                log.Info(String.Format("Got request for acronym \"{0}\".", acronym));
                char[] acroChars = acronym.ToCharArray();
                String[] outputStr = new String[acroChars.Length];
                int i = 0;

                foreach (char letter in acroChars) {
                    try {
                        List<String> letterList = wordList[letter];
                        outputStr[i] = letterList[random.Next(letterList.Count)];
                    }
                    catch (Exception) {
                        outputStr[i] = Char.ToString(letter);
                    }
                    i++;
                }

                String expansion = String.Join(" ", outputStr);

                CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                TextInfo textInfo = cultureInfo.TextInfo;
                expansion = textInfo.ToTitleCase(expansion);

                log.Info(String.Format("Ended up with the expansion \"{0}\".", expansion));

                message.Chat.SendMessage(String.Format(@"As far as I know, the acronym ""{0}"" means ""{1}"".", acronym, expansion));
            }
        }
Esempio n. 10
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"(?:youtube\.\w{2,3}\S+v=|youtu\.be/)([\w-]+)", RegexOptions.IgnoreCase);
            // Use non-breaking space as a marker for when to not show info.
            if (output.Success && !message.Body.Contains(" ")) {
                String youtubeId = output.Groups[1].Value;
                log.Info("Sending request to YouTube...");

                YouTubeQuery ytq = new YouTubeQuery("http://gdata.youtube.com/feeds/api/videos/" + youtubeId);

                Feed<Video> feed = ytr.Get<Video>(ytq);
                Video vid = feed.Entries.ElementAt<Video>(0);
                String title = vid.Title;
                String user = vid.Author;
                String rating = vid.RatingAverage.ToString();

                int seconds = Int32.Parse(vid.Media.Duration.Seconds) % 60;
                int minutes = Int32.Parse(vid.Media.Duration.Seconds) / 60;
                String duration = String.Format(@"{0}:{1:00}", minutes, seconds);

                message.Chat.SendMessage(String.Format(@"YouTube: ""{0}"" (uploaded by: {1}) (avg rating: {2:F2}) (duration: {3})", title, user, rating, duration));
                return;
            }
            
            output = Regex.Match(message.Body, @"^!youtube (.+)", RegexOptions.IgnoreCase);
            if (output.Success) {
                String query = output.Groups[1].Value;

                YouTubeQuery ytq = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
                ytq.Query = query;
                ytq.SafeSearch = YouTubeQuery.SafeSearchValues.None;
                ytq.NumberToRetrieve = 10;

                Feed<Video> feed = ytr.Get<Video>(ytq);
                int count = feed.Entries.Count<Video>();

                string url;
                if (count > 0) {
                    Video vid = feed.Entries.ElementAt<Video>(random.Next(count));
                    url = vid.WatchPage.ToString();
                } else {
                    url = "No matches found.";
                }

                message.Chat.SendMessage(String.Format(@"YouTube search for ""{0}"": {1}", query, url));
                return;
            }

            output = Regex.Match(message.Body, @"^!youtube", RegexOptions.IgnoreCase);
            if (output.Success) {
                log.Debug("Got a request for a random video.");

                String url = randomCache.Count > 0 ? randomCache.Dequeue() : generateRandomVideos(true);

                message.Chat.SendMessage(String.Format(@"Random YouTube video: {0}", url));

                generateRandomVideos(false);
                return;
            }
        }
Esempio n. 11
0
 private void MessageProcessor(ChatMessage msg, TChatMessageStatus status)
 {
     if (!IsLocalUser(msg)) return;
     var response = _messageProcessor.Process(msg.Body);
     if(response.Success)
     {
         _skype.SendMessage(msg.Sender.Handle, response.Message);
     }
 }
Esempio n. 12
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!overheard ?(\w*)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            if (output.Success) {
                log.Info("It's a-me! Determining active site...");
                OverheardSite activeSite = null;

                if (output.Groups[1].Length > 0) {
                    activeSite = (from site in sites
                                  where site.command == output.Groups[1].Value.ToLower()
                                  select site).SingleOrDefault();
                }

                if (activeSite == null) {
                    log.Info("Site not found or not chosen; picking at random...");
                    activeSite = sites[random.Next(sites.Length)];
                }

                log.Info("Picked " + activeSite.prettyName + "; fetching random quote...");
                WebRequest webReq = WebRequest.Create("http://www." + activeSite.urlname + "/bin/randomentry.cgi");
                webReq.Timeout = 10000;
                WebResponse response = webReq.GetResponse();
                log.Info("Response received; parsing...");
                String responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();

                Regex quoteRx = new Regex(@"
                        <h3\sclass=""title"">(.+?)</h3>
                        \s*
                        <p>(.+?)</p>
                    ",
                    RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline
                );

                Match quoteMatch = quoteRx.Match(responseText);
                if (!quoteMatch.Success) {
                    log.Warn("Regex failed to match contents. Please file a bug report about this if the problem persists.");
                    message.Chat.SendMessage("Sorry, something went wrong. :(");
                    return;
                }

                String title = quoteMatch.Groups[1].Value;
                String contents = quoteMatch.Groups[2].Value;

                title = title.Trim();

                contents = contents.Replace("<br/>", "\n");
                contents = Regex.Replace(contents, "<.+?>", "");
                contents = HttpUtility.HtmlDecode(contents);

                message.Chat.SendMessage(String.Format(
                    "{0}: {1}\n{2}",
                    activeSite.prettyName,
                    title,
                    contents
                ));
            }
        }
Esempio n. 13
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"^!8ball", RegexOptions.IgnoreCase);
            if (output.Success) {
                String reply = PluginSettings.Default.EightBallReplies[random.Next(PluginSettings.Default.EightBallReplies.Count)];

                message.Chat.SendMessage(String.Format(
                    @"The Magic 8-ball replies: {0}",
                    reply
                ));
            }
        }
Esempio n. 14
0
 public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
     Match output = Regex.Match(message.Body, @"^!wiki ?(.*)", RegexOptions.IgnoreCase);
     if (output.Success) {
         String query = output.Groups[1].Value.Trim();
         if (query.Length > 0) {
             lookupArticle(message, query);
         } else {
             findRandomPage(message);
         }
     }
 }
Esempio n. 15
0
 /// <summary>
 /// The skype on message status.
 /// </summary>
 /// <param name="chatMessage">
 /// The p message.
 /// </param>
 /// <param name="status">
 /// The status.
 /// </param>
 private void SkypeOnMessageStatus(ChatMessage chatMessage, TChatMessageStatus status)
 {
     if (status == TChatMessageStatus.cmsSent || status == TChatMessageStatus.cmsReceived)
     {
         if (chatMessage.Body.Equals("!about"))
         {
             chatMessage.Chat.SendMessage("This is skypnet bot.");
             chatMessage.Chat.SendMessage("There are " + ModuleManager.Modules.Count() + " modules.");
             chatMessage.Chat.SendMessage("Type !help to get more information about modules and how to use them.");
         }
     }
 }
Esempio n. 16
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"^!qdb ?(\d*)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            if (output.Success) {
                WebRequest webReq;
                WebResponse response;
                String responseText;
                String quoteText;
                Quote quote;

                if (output.Groups[1].Value != "") {
                    log.Info("No cached quotes; fetching...");
                    webReq = WebRequest.Create("http://qdb.us/qdb.xml?action=quote&quote="+output.Groups[1].Value+"&fixed=0&client=Dynamic+Skype+Bot");
                    webReq.Timeout = 10000;
                    response = webReq.GetResponse();
                    responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();

                    if (responseText == "no quotes were found for these parameters.") {
                        message.Chat.SendMessage("No quote exists with that id.");
                        return;
                    }

                    XDocument doc = XDocument.Parse(responseText);
                    XNamespace d = "http://purl.org/rss/1.0/";

                    XElement item = doc.Descendants(d + "item").First();
                    quote = new Quote();
                    quote.id = item.Element(d + "title").Value;

                    quoteText = item.Element(d + "description").Value;
                    quoteText = Regex.Replace(quoteText, "<br>", "\n\n");
                    quoteText = Regex.Replace(quoteText, "<.+?>", "");
                    quoteText = HttpUtility.HtmlDecode(quoteText);

                    quote.quote = quoteText;
                } else {
                    log.Info("Fetching random quote...");

                    if (randomQuotes.Count == 0) {
                        log.Info("No cached quotes; fetching...");
                        fetchRandomQuotes();
                    }

                    log.Debug("Picking a random quote...");
                    quote = randomQuotes.Dequeue();
                }

                message.Chat.SendMessage(String.Format(
                    "QDB Quote {0}:\n\n{1}",
                    quote.id,
                    quote.quote
                ));
            }
        }
Esempio n. 17
0
        private void skype_MessageStatus(ChatMessage msg, TChatMessageStatus status)
        {
            // Proceed only if the incoming message is a trigger
            if (msg.Body.IndexOf(trigger) >= 0)
            {
                // Remove trigger string and make lower case
                string command = msg.Body.Remove(0, trigger.Length).ToLower();

                // Send processed message back to skype chat window
                skype.SendMessage(msg.Sender.Handle, nick + " Says: " + ProcessCommand(command));
            }
        }
Esempio n. 18
0
 public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
     Match output = Regex.Match(message.Body, @"^!cypher ([^ ]+) (.*)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
     if (output.Success) {
         String cypher = output.Groups[1].Value;
         String plainText = output.Groups[2].Value;
         Match rotMatch = Regex.Match(cypher, @"^rot(\d+)$", RegexOptions.IgnoreCase);
         if (rotMatch.Success) {
             int rot = int.Parse(rotMatch.Groups[1].Value)%26;
             String code = caesar(plainText, rot);
             message.Chat.SendMessage(String.Format("ROT{0} of \"{1}\" is \"{2}\".", rot, plainText, code));
         }
     }
 }
Esempio n. 19
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!8ball", RegexOptions.IgnoreCase);

            if (output.Success)
            {
                String reply = PluginSettings.Default.EightBallReplies[random.Next(PluginSettings.Default.EightBallReplies.Count)];

                message.Chat.SendMessage(String.Format(
                                             @"The Magic 8-ball replies: {0}",
                                             reply
                                             ));
            }
        }
Esempio n. 20
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!rule34 (.+)", RegexOptions.IgnoreCase);

            if (output.Success)
            {
                String query     = output.Groups[1].Value;
                String searchUri = "http://rule34.paheal.net/post/list?search=" + System.Uri.EscapeDataString(query);

                log.Info(String.Format("Searching rule34 for '{0}'", query));
                HttpWebRequest webReq = (HttpWebRequest)HttpWebRequest.Create("http://rule34.paheal.net/post/list/" + System.Uri.EscapeDataString(query) + "/1");
                webReq.Timeout           = 20000;
                webReq.AllowAutoRedirect = true;
                WebResponse response;
                try {
                    response = webReq.GetResponse();
                } catch (WebException e) {
                    if (e.Status == WebExceptionStatus.ProtocolError && e.Response != null &&
                        ((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.NotFound)
                    {
                        message.Chat.SendMessage(String.Format("Sorry, couldn't find any rule34 pictures of {0}.", query));
                        return;
                    }
                    else
                    {
                        log.Warn("rule34.paheal.net appears to be unavailable at the moment.");
                        message.Chat.SendMessage("Sorry, the website failed to respond in time. It may be down, or just slow.\nIf you want to try the search for yourself, go to http://rule34.paheal.net/post/list?search=" + System.Uri.EscapeDataString(query));
                        return;
                    }
                }

                String          responseText  = new StreamReader(response.GetResponseStream()).ReadToEnd();
                Regex           imgFinderRx   = new Regex(@"<a href=""([^""]*?)"">Image Only</a>", RegexOptions.Singleline);
                MatchCollection imgFinderColl = imgFinderRx.Matches(responseText);
                if (imgFinderColl.Count <= 0)
                {
                    message.Chat.SendMessage(String.Format("Sorry, couldn't find any rule34 pictures of {0}.", query));
                    return;
                }
                Match imgFinder = imgFinderColl[random.Next(imgFinderColl.Count)];
                log.Info("Picture found! Linking to chat.");

                message.Chat.SendMessage(String.Format(
                                             @"Rule 34 picture of {0}: {1}",
                                             query,
                                             HttpUtility.UrlPathEncode(imgFinder.Groups[1].Value)
                                             ));
            }
        }
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"^!notright", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            if (output.Success) {
                WebRequest webReq = WebRequest.Create("http://notalwaysright.com/?random");
                webReq.Timeout = 10000;
                log.Info("Connecting to NotAlwaysRight.com...");

                WebResponse response = webReq.GetResponse();
                log.Info("Response received; parsing...");
                String responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();

                Regex notRightRx = new Regex(@"
                        <h3\sclass=""storytitle""><.+?>(.+?)</a>\s*</h3>\s*     # title
                        <div\sclass=""post_header""><a .*?rel=""tag"">(.+?)</a> # job text
                        \s\|\s(.+?)\s\|                                         # location
                        .+?
                        <div\sclass=""storycontent"">(.+?)</div>       # story
                    ",
                    RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline
                );

                Match match = notRightRx.Match(responseText);
                if (!match.Success) {
                    log.Warn("Couldn't find any stories. If this problem persists, please file a bug report.");
                    message.Chat.SendMessage("Sorry, I couldn't find any stories.");
                    return;
                }

                String title = match.Groups[1].Value;
                String job = String.Format("{0} &ndash; {1}", match.Groups[2].Value, match.Groups[3].Value);
                String story = match.Groups[4].Value;

                title = HttpUtility.HtmlDecode(title);
                title = title.Trim();

                job = Regex.Replace(job, "<.+?>", "");
                job = HttpUtility.HtmlDecode(job);
                job = job.Trim();

                story = Regex.Replace(story, "<.+?>", "");
                story = HttpUtility.HtmlDecode(story);
                story = story.Trim();

                message.Chat.SendMessage(String.Format(
                    "Not Always Right: {0}\n{1}\n\n{2}",
                    title, job, story
                ));
            }
        }
Esempio n. 22
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!p**n", RegexOptions.IgnoreCase);
            if (output.Success) {
                log.Debug("Loading category list...");
                WebRequest webReq = WebRequest.Create("http://www.easygals.com/");
                webReq.Timeout = 10000;
                WebResponse response = webReq.GetResponse();
                String responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();
                log.Debug("Picking a category...");
                Regex categoryFinderRx = new Regex(@"<a class=""catLink"" href=""([^\s]+)"".*?>(.+?)</a>");
                MatchCollection categoryFinderColl = categoryFinderRx.Matches(responseText);
                if (categoryFinderColl.Count <= 0) {
                    log.Warn("Couldn't find any p**n categories.");
                    log.Warn("Please check if http://www.easygals.com/ works okay for you.");
                    log.Warn("If it appears to work fine and the problem persists, please submit a bug report.");
                    message.Chat.SendMessage("Sorry, some kind of error occurred in trying to obtain p**n. :(");
                    return;
                }
                Match categoryFinder = categoryFinderColl[random.Next(categoryFinderColl.Count)];

                log.Info("I think I'll go for some " + categoryFinder.Groups[2].Value + " today!");

                log.Debug("Attempting to find some " + categoryFinder.Groups[2].Value + "...");

                webReq = WebRequest.Create("http://www.easygals.com/" + categoryFinder.Groups[1].Value + "&rs=1");
                webReq.Timeout = 10000;
                response = webReq.GetResponse();
                responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();
                Regex pornFinderRx = new Regex(@"<a href=""/cgi-bin/atx/out.+?u=(http:.+?)""");
                MatchCollection pornFinderColl = pornFinderRx.Matches(responseText);
                if (pornFinderColl.Count <= 0) {
                    log.Warn("Couldn't find any " + categoryFinder.Groups[2].Value + " p**n.");
                    log.Warn("Either the category is empty or the format of the site has changed.");
                    log.Warn("Please check if http://www.easygals.com/" + categoryFinder.Groups[1].Value + "&rs=1 loads okay.");
                    log.Warn("If it appears to work fine and the problem persists, please submit a bug report.");
                    message.Chat.SendMessage("Argh, I couldn't find any " + categoryFinder.Groups[2].Value + "! Bummer.");
                    return;
                }
                Match pornFinder = pornFinderColl[random.Next(pornFinderColl.Count)];

                log.Info("P**n found! Linking to chat.");

                message.Chat.SendMessage(String.Format(
                    @"Random p**n link: {0}",
                    pornFinder.Groups[1].Value
                ));
            }
        }
Esempio n. 23
0
 void Skype_MessageStatus(SKYPE4COMLib.ChatMessage pMessage, TChatMessageStatus Status)
 {
     try
     {
         if (Status.Equals(TChatMessageStatus.cmsReceived))
         {
             Trigger();
         }
     }
     catch (Exception ex)
     {
         ErrorLog.AddError(ErrorType.Failure, string.Format(Strings.Error_EventCantBeTriggered, Strings.ReceiveChatMessage_Title));
         Logger.Write(ex);
     }
 }
Esempio n. 24
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!link", RegexOptions.IgnoreCase);
            if (output.Success) {
                log.Info("Fetching link...");
                WebRequest webReq = WebRequest.Create("http://del.icio.us/recent?random");
                webReq.Timeout = 10000;
                WebResponse response = webReq.GetResponse();

                message.Chat.SendMessage(String.Format(
                    @"Random link: {0}",
                    response.ResponseUri
                ));
            }
        }
Esempio n. 25
0
 private void SkypeOnMessageStatus(ChatMessage pMessage, TChatMessageStatus status)
 {
     if (status == TChatMessageStatus.cmsReceived)
     {
         if (!_wHolder.DoesRoomExist(pMessage.Chat.FriendlyName))
         {
             _wHolder.CreateRoom(pMessage.ChatName, pMessage.Chat);
         }
         //_wHolder.GetMainWindow()
         //    .AddItem("STATUS: " + status, "SYSTEM", pMessage.Chat.FriendlyName.Split('|')[0]);
         _wHolder.GetMainWindow()
         .AddItem(pMessage.Body, pMessage.FromDisplayName, pMessage.Chat.FriendlyName.Split('|')[0]);
         pMessage.Seen = true;
     }
 }
 private void SkypeOnMessageStatus(ChatMessage pMessage, TChatMessageStatus status)
 {
     if (status == TChatMessageStatus.cmsReceived)
     {
         if (!_wHolder.DoesRoomExist(pMessage.Chat.FriendlyName))
         {
             _wHolder.CreateRoom(pMessage.ChatName, pMessage.Chat);
         }
         //_wHolder.GetMainWindow()
         //    .AddItem("STATUS: " + status, "SYSTEM", pMessage.Chat.FriendlyName.Split('|')[0]);
         _wHolder.GetMainWindow()
             .AddItem(pMessage.Body, pMessage.FromDisplayName, pMessage.Chat.FriendlyName.Split('|')[0]);
         pMessage.Seen = true;
     }
 }
Esempio n. 27
0
 static void skype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
 {
     if (pMessage.Body.IndexOf(trigger) == 0)
     {
         string command = pMessage.Body.Remove(0, trigger.Length).ToLower();
         //skype.SendMessage(pMessage.Sender.Handle, nick + " says: " + ProcessCommand(command));
         //skype.SendMessage(pMessage.Sender.Handle, skype.Friends.Count.ToString());
         //foreach (User name in skype.Friends)
         //{
         //    skype.SendMessage(pMessage.Sender.Handle, name.Handle + ":" + name.FullName);
         //}
         skype.SendMessage(pMessage.Sender.Handle, "I am a Bot");
         skype.SendMessage("nhattuan.tran.en", "Hello: " + command);
     }
 }
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"^!dA", RegexOptions.IgnoreCase);
            if (output.Success) {
                log.Info("Requesting random page...");
                WebRequest webReq = WebRequest.Create("http://www.deviantart.com/random/deviation");
                webReq.Timeout = 10000;
                WebResponse response = webReq.GetResponse();
                log.Debug("Gotcha!");

                message.Chat.SendMessage(String.Format(
                    @"Random deviation: {0}",
                    response.ResponseUri
                ));
            }
        }
        private void Skype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
        {
            if (Status == TChatMessageStatus.cmsSending)
            {
                if (OnBreakRegex.IsMatch(pMessage.Body))
                {
                    if (skypeManager.Logger.IsDebugEnabled)
                    {
                        skypeManager.Logger.Debug("OnBreakBehaviour");
                    }

                    skypeManager.Skype.ChangeUserStatus(TUserStatus.cusAway);
                }
            }
        }
Esempio n. 30
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"^!4chan", RegexOptions.IgnoreCase);
            if (output.Success) {
                log.Info("Going to visit /b/ to find a thread...");
                WebRequest webReq = WebRequest.Create("http://boards.4chan.org/b/");
                webReq.Timeout = 10000;
                WebResponse response;
                try {
                    response = webReq.GetResponse();
                } catch (WebException) {
                    log.Warn("4chan.org appears to be unavailable at the moment.");
                    message.Chat.SendMessage("Sorry, some kind of error occurred in trying to contact 4chan.");
                    return;   
                }
                String responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();
                Regex threadFinderRx = new Regex(@"<a href=""thread/(\d+)/[^""]+""[^>]*>Reply</a>");
                MatchCollection threadFinderColl = threadFinderRx.Matches(responseText);
                if (threadFinderColl.Count <= 0) {
                    log.Warn("4chan appears to have changed its thread-list format. Please report this on the suggestion page.");
                    message.Chat.SendMessage("Sorry, some kind of error occurred in trying to contact 4chan.");
                    return;
                }
                Match threadFinder = threadFinderColl[random.Next(threadFinderColl.Count)];
                

                log.Info("Thread located. Opening thread...");
                String threadId = threadFinder.Groups[1].Value;
                webReq = WebRequest.Create("http://boards.4chan.org/b/thread/"+threadId);
                response = webReq.GetResponse();
                responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();
                log.Info("Thread opened. Locating a random picture...");
                Regex picFinderRx = new Regex(@"<a class=""fileThumb"" href=""//i\.4cdn\.org/b/(\d+\.\w+)"" target=""_blank"">");
                MatchCollection picFinderColl = picFinderRx.Matches(responseText);
                if (picFinderColl.Count <= 0) {
                    log.Warn("For some reason, we couldn't find a picture on the page. Please report this on the suggestion page.");
                    message.Chat.SendMessage("Sorry, some kind of error occurred in trying to contact 4chan.");
                    return;
                }
                Match picFinder = picFinderColl[random.Next(picFinderColl.Count)];

                log.Warn("Picture found! Linking to chat.");

                message.Chat.SendMessage(String.Format(
                    @"Random picture from 4chan: http://i.4cdn.org/b/{0}",
                    picFinder.Groups[1].Value
                ));
            }
        }
Esempio n. 31
0
 private void AxSkype1_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
 {
     if (Status == TChatMessageStatus.cmsSent)
     {
         string Behind = pMessage.Body.Split('#')[1].Trim();
         string Front  = pMessage.Body.Split('#')[0].Trim();
         if (Front == "검색")
         {
             pMessage.Body = "[방인원리스트]";
             for (int i = 1; i <= pMessage.Chat.Members.Count; i++)
             {
                 pMessage.Body = pMessage.Body + "\r\n" + pMessage.Chat.MemberObjects[i].Handle + " (" + pMessage.Chat.Members[i].FullName + ")" + " [" + pMessage.Chat.MemberObjects[i].Role + "]";
             }
         }
     }
 }
Esempio n. 32
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!rule34 (.+)", RegexOptions.IgnoreCase);
            if (output.Success) {
                String query = output.Groups[1].Value;
                String searchUri = "http://rule34.paheal.net/post/list?search=" + System.Uri.EscapeDataString(query);

                log.Info(String.Format("Searching rule34 for '{0}'", query));
                WebRequest webReq = WebRequest.Create(searchUri);
                webReq.Timeout = 20000;
                try {
                    webReq.GetResponse();
                } catch (WebException) {
                    log.Warn("rule34.paheal.net appears to be unavailable at the moment.");
                    message.Chat.SendMessage("Sorry, the website failed to respond in time. It may be down, or just slow.\nIf you want to try the search for yourself, go to http://rule34.paheal.net/post/list?search=" + System.Uri.EscapeDataString(query));
                    return;
                }
                log.Info("Search completed; looking up result...");

                webReq = WebRequest.Create("http://rule34.paheal.net/post/list/" + System.Uri.EscapeDataString(query) + "/1");
                webReq.Timeout = 20000;
                WebResponse response;
                try {
                    response = webReq.GetResponse();
                } catch (WebException) {
                    log.Warn("rule34.paheal.net appears to be unavailable at the moment.");
                    message.Chat.SendMessage("Sorry, the website failed to respond in time. It may be down, or just slow.\nIf you want to try the search for yourself, go to http://rule34.paheal.net/post/list?search=" + System.Uri.EscapeDataString(query));
                    return;
                }

                String responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();
                Regex imgFinderRx = new Regex(@"(?<=id='Imagesmain-toggle'.*)<a href='([^']*?)'>Image Only</a>", RegexOptions.Singleline);
                MatchCollection imgFinderColl = imgFinderRx.Matches(responseText);
                if (imgFinderColl.Count <= 0) {
                    message.Chat.SendMessage(String.Format("Sorry, couldn't find any rule34 pictures of {0}.", query));
                    return;
                }
                Match imgFinder = imgFinderColl[random.Next(imgFinderColl.Count)];
                log.Info("Picture found! Linking to chat.");

                message.Chat.SendMessage(String.Format(
                    @"Rule 34 picture of {0}: {1}",
                    query,
                    HttpUtility.UrlPathEncode(imgFinder.Groups[1].Value)
                ));
            }
        }
Esempio n. 33
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!cypher ([^ ]+) (.*)", RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (output.Success)
            {
                String cypher    = output.Groups[1].Value;
                String plainText = output.Groups[2].Value;
                Match  rotMatch  = Regex.Match(cypher, @"^rot(\d+)$", RegexOptions.IgnoreCase);
                if (rotMatch.Success)
                {
                    int    rot  = int.Parse(rotMatch.Groups[1].Value) % 26;
                    String code = caesar(plainText, rot);
                    message.Chat.SendMessage(String.Format("ROT{0} of \"{1}\" is \"{2}\".", rot, plainText, code));
                }
            }
        }
Esempio n. 34
0
        private void skype_MessageStatus(ChatMessage message, TChatMessageStatus status)
        {
            if (status == TChatMessageStatus.cmsReceived)
            {
                // Get commands as text messages from User Skype Driver
                SkypeAutoHelper.Command command = SkypeAutoHelper.Command.Create(message.Body);

                switch (command.Name)
                {
                case "screenbounds":
                    UserData.Instance.ScreenBounds = new Size(int.Parse(command.Params[0]), int.Parse(command.Params[1]));
                    break;
                }

                SkypeAutomation.SkypeObj.ClearChatHistory();
            }
        }
Esempio n. 35
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!wiki ?(.*)", RegexOptions.IgnoreCase);

            if (output.Success)
            {
                String query = output.Groups[1].Value.Trim();
                if (query.Length > 0)
                {
                    lookupArticle(message, query);
                }
                else
                {
                    findRandomPage(message);
                }
            }
        }
Esempio n. 36
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match input = Regex.Match(message.Body, @"^!maze (.+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            if (input.Success) {
                Command cmd = CommandFromString(input.Groups[1].Value.ToLower());

                log.Debug("Got the command '" + cmd + "'");

                String output = "";

                switch (cmd) {
                    case Command.North:
                    case Command.South:
                    case Command.East:
                    case Command.West:
                    case Command.N:
                    case Command.E:
                    case Command.S:
                    case Command.W:
                        Direction dir = Direction.FromString(cmd.ToString());
                        if (control.Walker.CanWalk(dir)) {
                            control.Walker.Walk(dir);
                            output += reporter.ReportWalk(dir);
                        } else {
                            output += reporter.ReportCannotWalk;
                        }
                        break;
                    case Command.Down:
                        if (control.Walker.Position.HasDown) {
                            control.Descend();
                            output += reporter.ReportDescend;
                        } else {
                            output += reporter.ReportCannotDescend;
                        }
                        break;
                    case Command.Look:
                        output += reporter.ReportLook;
                        break;
                    default:
                        output += "Invalid command!";
                        break;
                }

                message.Chat.SendMessage(output);
            }
        }
Esempio n. 37
0
        public void Skype_MessageStatus(IChatMessage ichatmessage, TChatMessageStatus Status)
        {
            // Write Message Status to Window
            //if (ichatmessage.Type  == TChatMessageType.cmeSaid)
            //    return;
            if ((ichatmessage.Status != TChatMessageStatus.cmsReceived))
            {
                return;
            }

            this.textBox1.AppendText("Message Status: " + skype.Convert.ChatMessageStatusToText(Status));
            this.textBox1.AppendText(" - " + Status.ToString() + Environment.NewLine);
            string botsAnswer = pi.chatWithPrelude(ichatmessage.Body);

            this.textBox1.AppendText("Prelude: " + botsAnswer);
            ichatmessage.Chat.SendMessage(botsAnswer);
            this.textBox1.ScrollToCaret();
        }
Esempio n. 38
0
        /// <summary>
        /// Handles incoming message.
        /// </summary>
        /// <param name="message">
        /// Received message.
        /// </param>
        /// <param name="status">
        /// Message status.
        /// </param>
        private void OnMessageReceived(ChatMessage message, TChatMessageStatus status)
        {
            if (status == TChatMessageStatus.cmsReceived)
            {
                if (!message.Sender.IsAuthorized || message.Sender.IsBlocked)
                {
                    this.logger.LogMessage(
                        string.Format("Receiving message from unauthorized/blocked user: <{0}>", message.Sender.Handle));

                    return;
                }

                SkypeContact contact = this.contactsManager.GetSkypeContact(message.Sender.Handle);
                SkypeChat    chat    = this.contactsManager.GetSkypeChat(message.ChatName);

                this.ReceiveMessage(contact, chat, message.Body);
            }
        }
Esempio n. 39
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!dA", RegexOptions.IgnoreCase);

            if (output.Success)
            {
                log.Info("Requesting random page...");
                WebRequest webReq = WebRequest.Create("http://www.deviantart.com/random/deviation");
                webReq.Timeout = 10000;
                WebResponse response = webReq.GetResponse();
                log.Debug("Gotcha!");

                message.Chat.SendMessage(String.Format(
                                             @"Random deviation: {0}",
                                             response.ResponseUri
                                             ));
            }
        }
Esempio n. 40
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!dict (.*)", RegexOptions.IgnoreCase);

            if (output.Success)
            {
                String queryString = output.Groups[1].Value;
                log.Info(String.Format(@"Performing dictionary lookup on ""{0}"".", queryString));

                XPathDocument  response = new XPathDocument("http://www.onelook.com/?w=" + queryString + "&xml=1");
                XPathNavigator nav      = response.CreateNavigator();

                XPathNodeIterator it = nav.Select("//OLQuickDef");

                String defPlural   = (it.Count > 1 ? "s" : "");
                String definitions = "";
                int    i           = 0;
                foreach (XPathNavigator def in it)
                {
                    if (i >= 5)
                    {
                        definitions += "\n\nMore than 5 matches found; only the first 5 are displayed.";
                        break;
                    }
                    definitions += Environment.NewLine + HttpUtility.HtmlDecode(def.Value.Trim());
                    i++;
                }

                if (definitions.Equals(""))
                {
                    message.Chat.SendMessage(String.Format(@"Unable to define ""{0}"".", queryString));
                }
                else
                {
                    message.Chat.SendMessage(
                        String.Format(
                            @"The word ""{0}"" has the following definition{1}:{2}",
                            queryString,
                            defPlural,
                            definitions)
                        );
                }
            }
        }
Esempio n. 41
0
        public void OurMessageStatus(ChatMessage chatmessage, TChatMessageStatus status)
        {
            // Always use try/catch with ANY Skype calls.
            try
            {

                // Write Message Status to Window.
                Console.WriteLine(DateTime.Now.ToLocalTime() + ": " +
                 "Message Status - Message Id: " + chatmessage.Id +
                 " - Chat Friendly Name: " + chatmessage.Chat.FriendlyName +
                 " - Chat Name: " + chatmessage.Chat.Name +
                 " - Converted Message Type: " + skype.Convert.ChatMessageTypeToText(chatmessage.Type) +
                 " - Message Type: " + chatmessage.Type +
                 " - Converted TChatMessageStatus Status: " + skype.Convert.ChatMessageStatusToText(status) +
                 " - TChatMessageStatus Status: " + status +
                 " - From Display Name: " + chatmessage.FromDisplayName +
                 " - From Handle: " + chatmessage.FromHandle);

                // Examples of checking lengths before adding to Window.
                if (chatmessage.Chat.Topic.Length > 0) Console.WriteLine(" - Topic: " + chatmessage.Chat.Topic);
                if (chatmessage.Body.Length > 0) Console.WriteLine(" - Body: " + chatmessage.Body);

                var client = new RestClient("http://localhost:8080/");
                var request = new RestRequest("/api/messages", Method.POST);
                request.AddParameter("user", chatmessage.FromDisplayName);
                if (chatmessage.Body.Length > 0)
                    request.AddParameter("body", chatmessage.Body);

                IRestResponse response = client.Execute(request);

            }
            catch (Exception e)
            {
                // Possibly old Skype4COM version, log an error, drop into debug if wanted.
                Console.WriteLine(DateTime.Now.ToLocalTime() + ": " +
                 "Message Status Event Fired - Bad Text" +
                 " - Exception Source: " + e.Source + " - Exception Message: " + e.Message +
                 "\r\n");

                // If the "Use Auto Debug" check box is checked and we are in debug, drop into debug here when retry, otherwise, prompt for action.

            }
        }
Esempio n. 42
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"^!rule34 (.+)", RegexOptions.IgnoreCase);
            if (output.Success) {
                String query = output.Groups[1].Value;
                String searchUri = "http://rule34.paheal.net/post/list?search=" + System.Uri.EscapeDataString(query);

                log.Info(String.Format("Searching rule34 for '{0}'", query));
                HttpWebRequest webReq = (HttpWebRequest) HttpWebRequest.Create("http://rule34.paheal.net/post/list/" + System.Uri.EscapeDataString(query) + "/1");
                webReq.Timeout = 20000;
                webReq.AllowAutoRedirect = true;
                WebResponse response;
                try {
                    response = webReq.GetResponse();
                } catch (WebException e) {
                    if (e.Status == WebExceptionStatus.ProtocolError && e.Response != null
                        && ((HttpWebResponse) e.Response).StatusCode == HttpStatusCode.NotFound) {
                        message.Chat.SendMessage(String.Format("Sorry, couldn't find any rule34 pictures of {0}.", query));
                        return;    
                    } else {
                        log.Warn("rule34.paheal.net appears to be unavailable at the moment.");
                        message.Chat.SendMessage("Sorry, the website failed to respond in time. It may be down, or just slow.\nIf you want to try the search for yourself, go to http://rule34.paheal.net/post/list?search=" + System.Uri.EscapeDataString(query));
                        return;
                    }
                }

                String responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();
                Regex imgFinderRx = new Regex(@"<a href=""([^""]*?)"">Image Only</a>", RegexOptions.Singleline);
                MatchCollection imgFinderColl = imgFinderRx.Matches(responseText);
                if (imgFinderColl.Count <= 0) {
                    message.Chat.SendMessage(String.Format("Sorry, couldn't find any rule34 pictures of {0}.", query));
                    return;
                }
                Match imgFinder = imgFinderColl[random.Next(imgFinderColl.Count)];
                log.Info("Picture found! Linking to chat.");

                message.Chat.SendMessage(String.Format(
                    @"Rule 34 picture of {0}: {1}",
                    query,
                    HttpUtility.UrlPathEncode(imgFinder.Groups[1].Value)
                ));
            }
        }
Esempio n. 43
0
        private void skype_MessageStatus(ChatMessage message, TChatMessageStatus status)
        {
            if (status == TChatMessageStatus.cmsReceived)
            {
                try
                {
                    SkypeAutoHelper.Command command = SkypeAutoHelper.Command.Create(message.Body);
                    if (command != null && command.UniqueCounter != uniqueMsgCount)
                    {
                        uniqueMsgCount = command.UniqueCounter;
                        Do(command.Name, command.Params);
                    }
                }
                catch (Exception e)
                {
                }

                SkypeAutomation.SkypeObj.ClearChatHistory();
            }
        }
 public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
     Match output = Regex.Match(message.Body, @"^!(?:calc|eval) (.+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
     if (output.Success) {
         String exp = output.Groups[1].Value;
         SemanticProcessor<MathToken> processor = new SemanticProcessor<MathToken>(new StringReader(exp), actions);
         ParseMessage parseMessage = processor.ParseAll();
         if (parseMessage == ParseMessage.Accept) {
             message.Chat.SendMessage(
                 String.Format(
                     "{0} = {1}",
                     exp,
                     ((Computable)processor.CurrentToken).GetValue()));
         } else {
             IToken token = processor.CurrentToken;
             message.Chat.SendMessage(string.Format("{0} ({1} on line {2}, column {3})",
                                                    parseMessage, token.Symbol,
                                                    token.Position.Line, token.Position.Column));
         }
     }
 }
Esempio n. 45
0
        /// <summary>
        /// The skype on message status.
        /// </summary>
        /// <param name="chatMessage">
        /// The chat message.
        /// </param>
        /// <param name="status">
        /// The status.
        /// </param>
        private void SkypeOnMessageStatus(ChatMessage chatMessage, TChatMessageStatus status)
        {
            if (status == TChatMessageStatus.cmsSent || status == TChatMessageStatus.cmsReceived)
            {
                Match match = UrlRegex.Match(chatMessage.Body);

                if (match.Success)
                {
                    var url     = match.Groups["url"].Value;
                    var trigger = match.Groups["service"].Value;

                    // If the service matches
                    if (trigger.ToLower().Equals(this.Trigger.ToLower()))
                    {
                        string shorten = this.urlShortenProvider.Shorten(url);
                        chatMessage.Chat.SendMessage(shorten);
                    }
                }
            }
        }
Esempio n. 46
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!text", RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (output.Success)
            {
                if (randomTexts.Count == 0)
                {
                    message.Chat.SendMessage("No random text messages available; try again in a few seconds.");
                }
                else
                {
                    message.Chat.SendMessage(randomTexts.Dequeue());
                }
                if (randomTexts.Count < 4)
                {
                    log.Debug("Running low on cached messages; refilling...");
                    fetchRandomTexts();
                }
            }
        }
Esempio n. 47
0
        /// <summary>
        /// The skype on message status.
        /// </summary>
        /// <param name="chatMessage">
        /// The chat message.
        /// </param>
        /// <param name="status">
        /// The status.
        /// </param>
        private void SkypeOnMessageStatus(ChatMessage chatMessage, TChatMessageStatus status)
        {
            if (status == TChatMessageStatus.cmsReceived || status == TChatMessageStatus.cmsSent)
            {
                // The trigger word for this ascii emote
                if (chatMessage.Body.StartsWith("!ascii", true, CultureInfo.InvariantCulture))
                {
                    var match = Regex.Match(chatMessage.Body);

                    if (match.Success)
                    {
                        var emote = match.Groups["emote"].Value;

                        if (emote.ToLower().Equals(this.Emote.ToLower()))
                        {
                            chatMessage.Chat.SendMessage(this.Art);
                        }
                    }
                }
            }
        }
Esempio n. 48
0
        /// <summary>
        /// The skype on message status.
        /// </summary>
        /// <param name="chatMessage">
        /// The chat message.
        /// </param>
        /// <param name="status">
        /// The status.
        /// </param>
        private void SkypeOnMessageStatus(ChatMessage chatMessage, TChatMessageStatus status)
        {
            if (status == TChatMessageStatus.cmsSent || status == TChatMessageStatus.cmsReceived)
            {
                Match match = UrbanRegex.Match(chatMessage.Body);

                if (match.Success)
                {
                    bool   urlRequested = match.Groups[1].Value.Equals("nu", StringComparison.InvariantCultureIgnoreCase);
                    string term         = match.Groups[2].Value;

                    UrbanResponse urbanResponse = this.UrbanService.Search(new UrbanRequest(term));

                    if (urbanResponse != null)
                    {
                        if (urbanResponse.Definition.HasValue())
                        {
                            string definition = "Definition: " + urbanResponse.Definition.Replace('\r', ' ').Replace('\n', ' ');
                            chatMessage.Chat.SendMessage(definition);
                        }

                        if (urbanResponse.Example.HasValue())
                        {
                            string example = "Example: " + urbanResponse.Example.Replace('\r', ' ').Replace('\n', ' ');
                            chatMessage.Chat.SendMessage(example);
                        }

                        if (urlRequested && urbanResponse.Url.HasValue())
                        {
                            string url = "Url: " + urbanResponse.Url;
                            chatMessage.Chat.SendMessage(url);
                        }
                    }
                    else
                    {
                        chatMessage.Chat.SendMessage(string.Format("Nothing for term '{0}' was found.", term));
                    }
                }
            }
        }
Esempio n. 49
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!urban (.*)", RegexOptions.IgnoreCase);

            if (output.Success)
            {
                String query = output.Groups[1].Value;

                WebRequest  req = (HttpWebRequest)HttpWebRequest.Create("http://api.urbandictionary.com/v0/define?page=1&term=" + System.Uri.EscapeDataString(query));
                WebResponse resp;
                try {
                    resp = req.GetResponse();
                } catch (WebException) {
                    log.Warn("UrbanDictionary appears to be unavailable at the moment.");
                    message.Chat.SendMessage("Sorry, I seem to be unable to contact UrbanDictionary.");
                    return;
                }

                String responseText = new StreamReader(resp.GetResponseStream()).ReadToEnd();
                var    defs         = (Hashtable)JSON.JsonDecode(responseText);

                if ((string)defs["response_type"] == "no_results")
                {
                    message.Chat.SendMessage(String.Format(@"UrbanDictionary lookup of ""{0}"": No results found.", query));
                }
                else
                {
                    var def = (defs["list"] as ArrayList)[0] as Hashtable;

                    message.Chat.SendMessage(String.Format(
                                                 "UrbanDictionary lookup of \"{0}\":\n\n{1}: {2}\n\n{3}",
                                                 query,
                                                 def["word"],
                                                 def["definition"],
                                                 def["example"]
                                                 ));
                }
            }
        }
Esempio n. 50
0
        /// <summary>
        /// チャットが飛んできたときに発生するイベントを処理するイベントハンドラ
        /// </summary>
        /// <param name="pMessage">イベントを発生させたチャットの詳細データ</param>
        /// <param name="status">イベントを発生させたチャットの状態</param>
        private void SkypeMessageStatus(ChatMessage pMessage, TChatMessageStatus status)
        {
            switch (status)
            {
            case TChatMessageStatus.cmsRead:
                break;

            case TChatMessageStatus.cmsReceived:
                _chatChangeHistoryDictionary.Add(pMessage.Id, pMessage);
                _growl.RunNotificationMessageStatus(pMessage, status, GetUserAvatar(pMessage.Sender.Handle));
                break;

            case TChatMessageStatus.cmsSending:
                break;

            case TChatMessageStatus.cmsSent:
                break;

            case TChatMessageStatus.cmsUnknown:
                break;
            }
        }
Esempio n. 51
0
        void skype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
        {
            switch (Status)
            {
            case TChatMessageStatus.cmsRead:
                break;

            case TChatMessageStatus.cmsReceived:
                break;

            case TChatMessageStatus.cmsSending:
                break;

            case TChatMessageStatus.cmsSent:
                break;

            case TChatMessageStatus.cmsUnknown:
                break;

            default:
                break;
            }
        }
Esempio n. 52
0
        private void skype_MessageStatus(ChatMessage msg,
                                         TChatMessageStatus status)
        {
            // Proceed only if the incoming message is a trigger
            if (msg.Body.IndexOf(trigger) == 0)
            {
                // Remove trigger string and make lower case
                string command = msg.Body.Remove(0, trigger.Length).ToLower();
                textBox1.Text = msg.Chat.FriendlyName;
                textBox2.Text = msg.Chat.Name;

                string groupname2;
                string groupname;
                groupname  = textBox1.Text;
                groupname2 = textBox2.Text;



                // Send processed message back to skype chat window
                // skype.SendMessage(msg.Sender.Handle, nick +
                //     " Says: " + ProcessCommand(command));
                msg.Chat.SendMessage(" " + ProcessCommand(command));
            }
        }
Esempio n. 53
0
        private void skype_MessageStatus(ChatMessage msg, TChatMessageStatus status)
        {
            var webAddr        = "http://81.2.243.96:8080/runtime/process-instances";
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(webAddr);

            httpWebRequest.ContentType = "application/json; charset=utf-8";
            System.Net.NetworkCredential userDefined = new System.Net.NetworkCredential("kermit", "kermit");
            httpWebRequest.Credentials = userDefined;
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = $"{{ \"processDefinitionId\":\"process:32:46610\",\"variables\": [{{\"name\":\"{msg.Sender.FullName}\",\"value\":\"{msg.Body}\",}}]}}";

                streamWriter.Write(json);
                streamWriter.Flush();
            }

            //var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            //using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            //{
            //    var result = streamReader.ReadToEnd();
            //}
        }
Esempio n. 54
0
        /// <summary>
        /// The skype on message status.
        /// </summary>
        /// <param name="chatMessage">
        /// The p message.
        /// </param>
        /// <param name="status">
        /// The status.
        /// </param>
        private void SkypeOnMessageStatus(ChatMessage chatMessage, TChatMessageStatus status)
        {
            if (status == TChatMessageStatus.cmsSent || status == TChatMessageStatus.cmsReceived)
            {
                Match match = DiceRegex.Match(chatMessage.Body);

                if (match.Success)
                {
                    var group = match.Groups["times"];

                    if (group.Success)
                    {
                        int value   = int.Parse(group.Value);
                        var results = new List <int>();
                        value.Times(() => results.Add(this.random.Next(1, 6)));
                        chatMessage.Chat.SendMessage(string.Join(", ", results));
                    }
                    else
                    {
                        chatMessage.Chat.SendMessage(this.random.Next(1, 6).ToString(CultureInfo.InvariantCulture));
                    }
                }
            }
        }
Esempio n. 55
0
        private void _skype_MessageStatus(ChatMessage m, TChatMessageStatus t)
        {
            if (t == TChatMessageStatus.cmsReceived || t == TChatMessageStatus.cmsSent)
            {
                lock (messagesListView)
                {
                    foreach (ListViewItem l in chatsListView.Items)
                    {
                        if (((SkypeChat)l.Tag).Name == m.Chat.Name)
                        {
                            SkypeMessage s = new SkypeMessage(m);

                            ((SkypeChat)l.Tag).addMessage(s);

                            if (_current != null && _current.Name == m.ChatName)
                            {
                                messagesListView.Items.Add(new ListViewItem(new string[] { s.Sender, s.Body, s.Timestamp.ToString() })
                                {
                                    Tag = s
                                });
                            }

                            return;
                        }
                    }

                    ListViewItem lvi = new ListViewItem(m.Chat.FriendlyName)
                    {
                        Tag = new SkypeChat(m.Chat)
                    };
                    chatsListView.Items.Insert(0, lvi);

                    ((SkypeChat)lvi.Tag).addMessage(new SkypeMessage(m));
                }
            }
        }
Esempio n. 56
0
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output = Regex.Match(message.Body, @"^!bash ?(.*)", RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (output.Success)
            {
                WebRequest  webReq;
                WebResponse response;
                String      responseText;

                int quoteNo;
                try {
                    quoteNo = int.Parse(output.Groups[1].Value);
                } catch (Exception) {
                    webReq         = WebRequest.Create("http://bash.org/?random");
                    webReq.Timeout = 10000;
                    log.Info("Finding random quote...");
                    response = webReq.GetResponse();
                    log.Info("Response received; parsing...");
                    responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();
                    Regex           quoteNoRx   = new Regex(@"<b>#(\d+)</b>");
                    MatchCollection quoteNoColl = quoteNoRx.Matches(responseText);
                    if (quoteNoColl.Count <= 0)
                    {
                        message.Chat.SendMessage("Sorry, some kind of error occurred in trying to contact bash.org.");
                        return;
                    }
                    Match quoteNoFinder = quoteNoColl[random.Next(quoteNoColl.Count)];
                    quoteNo = int.Parse(quoteNoFinder.Groups[1].Value);
                }

                log.Info("Fetching bash.org quote #" + quoteNo);
                webReq         = WebRequest.Create("http://bash.org/?" + quoteNo);
                webReq.Timeout = 10000;
                response       = webReq.GetResponse();
                log.Info("Response received; parsing...");
                responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();

                /*
                 * <p class="quote"><a href="?4680" title="Permanent link to this quote."><b>#4680</b>
                 * </a> <a href="./?le=373af74fe92bc1e44c88f68b427855c4&amp;rox=4680" class="qa">+</a>
                 * (6567)<a href="./?le=373af74fe92bc1e44c88f68b427855c4&amp;sox=4680" class="qa">-</a>
                 * <a href="./?le=373af74fe92bc1e44c88f68b427855c4&amp;sux=4680"
                 * onClick="return confirm('Flag quote for review?');" class="qa">[X]</a></p>
                 * <p class="qt">&lt;Raize&gt; can you guys see what I type? <br />
                 *
                 * &lt;vecna&gt; no, raize <br />
                 * &lt;Raize&gt; How do I set it up so you can see it?</p>*/
                Regex quoteRx = new Regex(
                    @"<p class=""quote"">.*\+</a>\((-?\d+)\)<a.*</p><p class=""qt"">(.*)</p>",
                    RegexOptions.Singleline | RegexOptions.IgnoreCase
                    );

                Match quoteMatch = quoteRx.Match(responseText);

                if (!quoteMatch.Success)
                {
                    log.Error("bash.org failed to respond or has changed format. Please submit bug report.");
                    message.Chat.SendMessage("Sorry, some kind of error occurred in trying to contact bash.org.");
                    return;
                }

                String rating = quoteMatch.Groups[1].Value;
                String quote  = quoteMatch.Groups[2].Value;

                quote = quote.Replace("<br />", "");
                quote = HttpUtility.HtmlDecode(quote);

                message.Chat.SendMessage(String.Format(
                                             "bash.org Quote #{0} ({1}):\n\n{2}",
                                             quoteNo,
                                             rating,
                                             quote
                                             ));
            }
        }
Esempio n. 57
0
        public void skype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
        {
            #region Speaker Commands

            if (Status != TChatMessageStatus.cmsRead && pMessage.FromHandle != "async.bot" && (speakerList.Items.Contains(pMessage.FromHandle) || masterList.Items.Contains(pMessage.FromHandle)))
            {
                if (pMessage.Body.ToString() == "ping")
                {
                    pMessage.Chat.SendMessage("[BOT]: pong");
                }
                else if (pMessage.Body.ToString() == "pong")
                {
                    pMessage.Chat.SendMessage("[BOT]: ping");
                }
                else if (pMessage.Body.ToString().StartsWith("!insult "))
                {
                    string speaker = pMessage.Body.ToString().Substring(("!insult ").Length, pMessage.Body.ToString().Length - ("!insult ").Length);

                    pMessage.Chat.SendMessage("[BOT]: " + speaker + " is fat, ugly and hapless.");
                }
                else if (pMessage.Body.ToString().StartsWith("!voteKick "))
                {
                    string speaker = pMessage.Body.ToString().Substring(("!voteKick ").Length, pMessage.Body.ToString().Length - ("!voteKick ").Length);

                    if (!TempUserListContains(speaker))
                    {
                        tempUsers.Add(new TempUser(speaker));
                    }

                    TempUser user = GetTempUser(speaker);

                    try
                    {
                        if (!user.voters.Contains(pMessage.FromHandle))
                        {
                            user.voteKick++;
                            user.voters.Add(pMessage.FromHandle);
                            pMessage.Chat.SendMessage("[BOT]: Thank-you for voting. Vote kick count now at: " + user.voteKick + ".");

                            if (user.voteKick >= 3)
                            {
                                pMessage.Chat.SendMessage("/kick " + speaker);
                                pMessage.Chat.SendMessage("[BOT]: Voting closed. Attempting to kick " + speaker + ".");
                            }
                        }
                        else
                        {
                            pMessage.Chat.SendMessage("[BOT]: " + pMessage.FromHandle + " has already voted!");
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace(ex.ToString());
                    }
                }
                else if (pMessage.Body.ToString().StartsWith("!voteKickAgainst "))
                {
                    string speaker = pMessage.Body.ToString().Substring(("!voteKickAgainst ").Length, pMessage.Body.ToString().Length - ("!voteKickAgainst ").Length);

                    if (!TempUserListContains(speaker))
                    {
                        tempUsers.Add(new TempUser(speaker));
                    }

                    TempUser user = GetTempUser(speaker);

                    if (!user.voters.Contains(pMessage.FromHandle))
                    {
                        user.voteKick--;
                        user.voters.Add(pMessage.FromHandle);
                        pMessage.Chat.SendMessage("[BOT]: Thank-you for voting. Vote kick count now at: " + user.voteKick + ".");

                        if (user.voteKick >= 3)
                        {
                            pMessage.Chat.SendMessage("/kick " + speaker);
                            pMessage.Chat.SendMessage("[BOT]: Voting closed. Attempting to kick " + speaker + ".");
                        }
                    }
                    else
                    {
                        pMessage.Chat.SendMessage("[BOT]: " + pMessage.FromHandle + " has already voted!");
                    }
                }
                else if (pMessage.Body.ToString().StartsWith("!respect "))
                {
                    string speaker = pMessage.Body.ToString().Substring(("!respect ").Length, pMessage.Body.ToString().Length - ("!respect ").Length);

                    if (!TempUserListContains(speaker))
                    {
                        tempUsers.Add(new TempUser(speaker));
                    }

                    TempUser user = GetTempUser(speaker);

                    if (!user.respecters.Contains(pMessage.FromHandle))
                    {
                        user.respect++;
                        user.respecters.Add(pMessage.FromHandle);
                        pMessage.Chat.SendMessage("[BOT]: " + speaker + " has now got " + user.respect + " respect.");
                    }
                    else
                    {
                        pMessage.Chat.SendMessage("[BOT]: " + pMessage.FromHandle + " has already voted!");
                    }
                }
                else if (pMessage.Body.ToString().ToLower().StartsWith("!help"))
                {
                    pMessage.Chat.SendMessage("Please keep in mind all commands are case-sensitive, and you must replace [username] with the username, NOT the display name!");
                    pMessage.Chat.SendMessage("!voteKick [username] - Votes in favour of kicking someone. When vote kick count reaches 3, user is automatically kicked.");
                    pMessage.Chat.SendMessage("!voteKickAgainst [username] - Votes against of kicking someone. When vote kick count reaches 3, user is automatically kicked.");
                    pMessage.Chat.SendMessage("!insult [username] - Insults user.");
                    pMessage.Chat.SendMessage("!respect [username] - Awards user some respect.");
                    pMessage.Chat.SendMessage("!ping [username] - Bot replies pong if it's listening to you.");
                    pMessage.Chat.SendMessage("!pong [username] - Bot replies ping if it's listening to you.");
                }
                else if (pMessage.Body.StartsWith("!compile "))
                {
                    string code = pMessage.Body.ToString().Substring(("!compile ").Length, pMessage.Body.ToString().Length - ("!compile ").Length);

                    if (File.Exists("code.cs"))
                    {
                        File.Delete("code.cs");
                    }

                    if (File.Exists("compile.bat"))
                    {
                        File.Delete("compile.bat");
                    }

                    File.AppendAllText("code.cs", "using System;using System.Threading; class Code { public static void closeIn1(){Thread.Sleep(1000);Environment.Exit(0);}\npublic static void Main(){ Thread t=new Thread(closeIn1);t.Start();");
                    File.AppendAllText("code.cs", code);
                    File.AppendAllText("code.cs", "}}");

                    string csc     = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe";
                    string command = csc + " /t:exe /o code.cs";

                    File.AppendAllText("compile.bat", command);

                    Process p = new Process();
                    p.StartInfo.FileName = "compile.bat";
                    p.StartInfo.RedirectStandardOutput = true;
                    p.StartInfo.UseShellExecute        = false;
                    p.StartInfo.RedirectStandardError  = true;
                    p.StartInfo.CreateNoWindow         = true;
                    p.Start();

                    string output = p.StandardOutput.ReadToEnd();
                    p.WaitForExit();

                    pMessage.Chat.SendMessage("[BOT]: Attempting to compile...");

                    if (!output.ToLower().Contains("error"))
                    {
                        pMessage.Chat.SendMessage("[BOT]: Compiled successfully. Attempting to run...");

                        Process p2 = new Process();
                        p2.StartInfo.FileName = "code.exe";
                        p2.StartInfo.RedirectStandardOutput = true;
                        p2.StartInfo.UseShellExecute        = false;
                        p2.StartInfo.RedirectStandardError  = true;
                        p2.StartInfo.CreateNoWindow         = true;
                        p2.Start();

                        string output2 = p2.StandardOutput.ReadToEnd();
                        p2.WaitForExit();

                        if (Regex.Matches(output2, "\n").Count > 5)
                        {
                            pMessage.Chat.SendMessage("[BOT]: Output too long to be displayed.");
                        }
                        else
                        {
                            pMessage.Chat.SendMessage("[BOT]: " + output2);
                        }
                    }
                    else
                    {
                        pMessage.Chat.SendMessage("[BOT]: I think it contains an error. I won't run it. You can !forceRun if you want though.");
                        pMessage.Chat.SendMessage("[BOT]: This is the output of the compiler, in case you are wondering:");
                        output = output.Substring(output.IndexOf("All rights reserved.") + ("ll rights reserved.").Length + 5);
                        pMessage.Chat.SendMessage("[BOT]: " + output);
                    }
                }
                else if (pMessage.Body == "!forceRun")
                {
                    Process p = new Process();
                    p.StartInfo.FileName = "code.exe";
                    p.StartInfo.RedirectStandardOutput = true;
                    p.StartInfo.UseShellExecute        = false;
                    p.StartInfo.RedirectStandardError  = true;
                    p.StartInfo.CreateNoWindow         = true;
                    p.Start();

                    string output = p.StandardOutput.ReadToEnd();
                    p.WaitForExit();

                    if (Regex.Matches(output, "\n").Count > 5)
                    {
                        pMessage.Chat.SendMessage("[BOT]: Output too long to be displayed.");
                    }
                    else
                    {
                        pMessage.Chat.SendMessage("[BOT]: " + output);
                    }
                }
            }

            #endregion


            #region Master-only commands

            if (masterList.Items.Contains(pMessage.FromHandle) || pMessage.FromHandle == "lucasfth")
            {
                if (pMessage.Body.ToString() == "!muteEveryone")
                {
                    Chat chat = pMessage.Chat;

                    foreach (IChatMember user in chat.MemberObjects)
                    {
                        if (!speakerList.Items.Contains(user.Handle) && user.Handle != "async.bot")
                        {
                            try
                            {
                                if (user.get_CanSetRoleTo(TChatMemberRole.chatMemberRoleListener))
                                {
                                    Command cmd = new Command();
                                    cmd.Blocking = false;
                                    cmd.Timeout  = 2000;
                                    cmd.Command  = "ALTER CHATMEMBER " + user.Id + " SETROLETO LISTENER";

                                    skype.SendCommand(cmd);

                                    listBox2.Items.Add("Sent command");
                                }
                                else
                                {
                                    listBox2.Items.Add("Can't set role to LISTENER");
                                }
                            }
                            catch (Exception ex)
                            {
                                listBox2.Items.Add(ex);
                            }
                        }
                    }

                    pMessage.Chat.SendMessage("[BOT]: Everyone outside speaker list muted.");
                }
                else if (pMessage.Body.ToString() == "!unmuteEveryone")
                {
                    Chat chat = pMessage.Chat;

                    foreach (IChatMember user in chat.MemberObjects)
                    {
                        if (!speakerList.Items.Contains(user.Handle) && user.Handle != "async.bot")
                        {
                            try
                            {
                                if (user.get_CanSetRoleTo(TChatMemberRole.chatMemberRoleUser))
                                {
                                    Command cmd = new Command();
                                    cmd.Blocking = false;
                                    cmd.Timeout  = 2000;
                                    cmd.Command  = "ALTER CHATMEMBER " + user.Id + " SETROLETO USER";

                                    skype.SendCommand(cmd);

                                    listBox2.Items.Add("Sent command");
                                }
                                else
                                {
                                    listBox2.Items.Add("Can't set role to USER");
                                }
                            }
                            catch (Exception ex)
                            {
                                listBox2.Items.Add(ex);
                            }
                        }
                    }

                    pMessage.Chat.SendMessage("[BOT]: Everyone outside speaker list unmuted.");
                }
                else if (pMessage.Body.ToString().StartsWith("!mute "))
                {
                    Chat chat = pMessage.Chat;

                    string speaker = pMessage.Body.ToString().Substring(("!mute ").Length, pMessage.Body.ToString().Length - ("!mute ").Length);

                    if (speakerList.Items.Contains(speaker))
                    {
                        speakerList.Items.Remove(speaker);
                    }

                    IChatMember user = null;

                    foreach (IChatMember u in chat.MemberObjects)
                    {
                        if (u.Handle == speaker)
                        {
                            user = u;
                            break;
                        }
                    }

                    if (user == null)
                    {
                        pMessage.Chat.SendMessage("[BOT]: User '" + user.Handle + "' doesn't exist");
                    }
                    else
                    {
                        if (user.get_CanSetRoleTo(TChatMemberRole.chatMemberRoleListener))
                        {
                            Command cmd = new Command();
                            cmd.Blocking = false;
                            cmd.Timeout  = 2000;
                            cmd.Command  = "ALTER CHATMEMBER " + user.Id + " SETROLETO LISTENER";

                            skype.SendCommand(cmd);

                            listBox2.Items.Add("Sent command");

                            pMessage.Chat.SendMessage("[BOT]: Muted " + speaker);
                        }
                        else
                        {
                            listBox2.Items.Add("Can't set role to LISTENER");
                        }
                    }
                }
                else if (pMessage.Body.ToString().StartsWith("!unmute "))
                {
                    Chat chat = pMessage.Chat;

                    string speaker = pMessage.Body.ToString().Substring(("!unmute ").Length, pMessage.Body.ToString().Length - ("!unmute ").Length);

                    if (speakerList.Items.Contains(speaker))
                    {
                        speakerList.Items.Remove(speaker);
                    }

                    IChatMember user = null;

                    foreach (IChatMember u in chat.MemberObjects)
                    {
                        if (u.Handle == speaker)
                        {
                            user = u;
                            break;
                        }
                    }

                    if (user == null)
                    {
                        pMessage.Chat.SendMessage("[BOT]: User '" + user.Handle + "' doesn't exist");
                    }
                    else
                    {
                        if (user.get_CanSetRoleTo(TChatMemberRole.chatMemberRoleUser))
                        {
                            Command cmd = new Command();
                            cmd.Blocking = false;
                            cmd.Timeout  = 2000;
                            cmd.Command  = "ALTER CHATMEMBER " + user.Id + " SETROLETO USER";

                            skype.SendCommand(cmd);

                            listBox2.Items.Add("Sent command");

                            pMessage.Chat.SendMessage("[BOT]: Unmuted " + speaker);
                        }
                        else
                        {
                            listBox2.Items.Add("Can't set role to USER");
                        }
                    }
                }
                else if (pMessage.Body.ToString().StartsWith("!kick "))
                {
                    string speaker = pMessage.Body.ToString().Substring(("!kick ").Length, pMessage.Body.ToString().Length - ("!kick ").Length);
                    pMessage.Chat.SendMessage("/kick " + speaker);
                    pMessage.Chat.SendMessage("[BOT]: Attempting to kick " + speaker);
                }
                else if (pMessage.Body.ToString().StartsWith("!ban "))
                {
                    string speaker = pMessage.Body.ToString().Substring(("!ban ").Length, pMessage.Body.ToString().Length - ("!ban ").Length);
                    pMessage.Chat.SendMessage("/ban " + speaker);
                    pMessage.Chat.SendMessage("[BOT]: Attempting to ban " + speaker);
                }
            }

            #endregion

            #region Supreme Master Commands

            if (pMessage.FromHandle == "lucasfth")
            {
                if (pMessage.Body.ToString().StartsWith("!addSpeaker "))
                {
                    string speaker = pMessage.Body.ToString().Substring(("!addSpeaker ").Length, pMessage.Body.ToString().Length - ("!addSpeaker ").Length);
                    speakerList.Items.Add(speaker);

                    pMessage.Chat.SendMessage("[BOT]: Added " + speaker + " to speaker list");
                }
            }

            #endregion
        }
        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
        {
            Match output  = Regex.Match(message.Body, @"forums.somethingawful.com/showthread.php.*threadid=(\d+)", RegexOptions.IgnoreCase);
            Match output2 = Regex.Match(message.Body, @"forums.somethingawful.com/showthread.php.*postid=(\d+)", RegexOptions.IgnoreCase);

            // Use non-breaking space as a marker for when to not show info.
            if ((output.Success || output2.Success) && !message.Body.Contains(" "))
            {
                log.Debug("Hey, it's my turn now!");

                String      url;
                WebRequest  webReq;
                WebResponse response;
                String      responseText;

                if (output.Success)
                {
                    log.Debug("Thread ID = " + output.Groups[1].Value);
                    url = "http://forums.somethingawful.com/showthread.php?threadid=" + output.Groups[1].Value;
                }
                else
                {
                    log.Debug("Post ID = " + output2.Groups[1].Value);
                    log.Info("Finding thread ID...");
                    webReq         = WebRequest.Create("http://forums.somethingawful.com/showthread.php?action=showpost&noseen=1&postid=" + output2.Groups[1].Value);
                    webReq.Timeout = 10000;
                    response       = webReq.GetResponse();
                    responseText   = new StreamReader(response.GetResponseStream()).ReadToEnd();

                    Match threadIDMatch = Regex.Match(responseText, @"<td class=""postdate"">.*threadid=(\d+).*</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    if (!threadIDMatch.Success)
                    {
                        log.Warn("Unable to find the thread in the live forums.");
                        log.Warn("If the thread is live and public, please file a bug report.");
                        message.Chat.SendMessage("Unable to find thread.");
                        return;
                    }
                    log.Debug("Thread ID = " + threadIDMatch.Groups[1].Value);
                    url = "http://forums.somethingawful.com/showthread.php?threadid=" + threadIDMatch.Groups[1].Value;
                }

                log.Debug("Fetching thread...");
                webReq         = WebRequest.Create(url);
                webReq.Timeout = 10000;
                response       = webReq.GetResponse();
                responseText   = new StreamReader(response.GetResponseStream()).ReadToEnd();

                log.Debug("Extracting information...");
                Match  titleMatch = Regex.Match(responseText, @"<a[^>]*class=""bclast""[^>]*>(.*)</a>", RegexOptions.IgnoreCase);
                String title      = titleMatch.Success ? titleMatch.Groups[1].Value : "Unknown Title";
                title = HttpUtility.HtmlDecode(title);

                Match  opMatch = Regex.Match(responseText, @"<dt class="".*?author.*?"".*?>(.*?)</dt>", RegexOptions.IgnoreCase);
                String op      = opMatch.Success ? opMatch.Groups[1].Value : "Unknown OP";
                op = HttpUtility.HtmlDecode(op);

                Match  forumMatch = Regex.Match(responseText, @">([^>]*)</a> &gt; <a[^>]*class=""bclast""[^>]*>", RegexOptions.IgnoreCase);
                String forum      = forumMatch.Success ? forumMatch.Groups[1].Value : "Unknown Subforum";
                forum = HttpUtility.HtmlDecode(forum);

                message.Chat.SendMessage(String.Format(
                                             "SA: {0} > {1} ({2})",
                                             forum,
                                             title,
                                             op
                                             ));
            }
        }
Esempio n. 59
0
 public MessageEvent(ChatMessage f, TChatMessageStatus g)
 {
     Status  = g;
     Message = f;
 }
Esempio n. 60
0
 public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status)
 {
     // Your code goes here. Yay!
 }