Exemplo n.º 1
0
        public bool Run(string MessageText, SlackRTM.Events.Message RawMessage, bool IsTargeted, SlackRTM.Slack Instance)
        {
            /* ****
            * Reminders.
            * ****/
            var match = Regex.Match(
                MessageText,
                @"Remind (?<Owner>me|(?<un>@[\w]+)) to (?<Text>.+)",
                RegexOptions.IgnoreCase);

            if (IsTargeted && match.Success)
            {
#if REMINDERS
                var target = Instance.GetUser(match.Groups["un"].Success ? match.Groups["un"].Value : RawMessage.User);
                Instance.SendMessage(RawMessage.Channel, string.Format("Ok. I'll remind {0} next time {1} in.", target.Name, "they're"));
                PersistentSingleton <Reminders> .Instance.Add(target, match.Groups["Text"].Value);

                PersistentSingleton <Reminders> .Instance.Check(Instance);

                return(true);
#else
                RawMessage.Reply(Instance, "This feature has been disabled.", true);
#endif
            }
            return(false);
        }
Exemplo n.º 2
0
        bool ICommand.Run(string MessageText, SlackRTM.Events.Message RawMessage, bool IsTargeted, SlackRTM.Slack Instance)
        {
            /* ****
            * That's my Something
            * ****/
            var match = Regex.Match(
                MessageText,
                @"That(['’]?s| is) (?<Owner>my|the|(?<un>@[\w-_.]+)['’]s) (?<Type>[\w ]+)?(,\s+?(?<Nickname>[\w _:]+))?",
                RegexOptions.IgnoreCase);

            if (match.Success)
            {
                if (!IsTargeted)
                {
                    //TODO: Rate Limit to once per day.
                    RawMessage.Reply(Instance, "Was that to me?");
                    return(true);
                }
                var LastHost = Instance.GetLastHost();
                if (LastHost == null)
                {
                    Instance.SendMessage(RawMessage.Channel, String.Format("@{0}: I have no idea what you're talking about.", Instance.GetUser(RawMessage.User).Name));
                    return(true);
                }
                LastHost.Type = match.Groups["Type"].Value;
                var Owner = match.Groups["Owner"].Value;
                switch (Owner)
                {
                case "my":
                    LastHost.Owner = Instance.GetUser(RawMessage.User).Name;
                    break;

                case "a":
                    if (string.IsNullOrEmpty(LastHost.Owner))
                    {
                        LastHost.Owner = "";
                        //LastHost.IsFixture = true;
                    }
                    break;

                case "the":
                    LastHost.Owner     = "?";
                    LastHost.IsFixture = true;
                    break;

                default:
                    LastHost.Owner = match.Groups["un"].Value;
                    break;
                }
                Instance.SendMessage(RawMessage.Channel, string.Format("Ok. {0} is {1}'s {2}.  I'll keep that in mind :simple_smile:", LastHost.FriendlyName, LastHost.Owner, LastHost.Type));
                Singleton <NetworkData> .Instance.Save();

                var another = Singleton <NetworkData> .Instance.PickIncompleteHost();

                if (another != null)
                {
                    RawMessage.Reply(Instance, string.Format("Also, do you recognise {0}?", another.FriendlyName), false);
                    Instance.SetLastHost(another);
                }
                return(true);
            }
            return(false);
        }