Ejemplo n.º 1
0
        public override bool chatEvent(message m, chat c = null)
        {
            bool processed = false;
            if (c != null) //Needs to be done in a chat!
            {
                if (m.text_msg.StartsWith("/birthday_add"))
                {
                    TelegramAPI.GetReply(m.chatID, "Whose birthday do you want to add?", m.message_id, true);
                    processed = true;
                }
                else if (m.text_msg.StartsWith("/birthday_remove"))
                {
                    TelegramAPI.GetReply(m.chatID, "Whose birthday do you want to remove?", m.message_id, true);
                    processed = true;
                }
                else if (m.isReply && m.replyOrigMessage == "Whose birthday do you want to add?" && m.replyOrigUser == Roboto.Settings.botUserName)
                {
                    //reply to add word
                    TelegramAPI.GetReply(m.chatID, "What birthday does " + m.text_msg + " have? (DD-MON-YYYY format, e.g. 01-JAN-1900)", m.message_id, true);
                    processed = true;
                }

                else if (m.isReply && m.replyOrigMessage.StartsWith("What birthday does ") && m.replyOrigUser == Roboto.Settings.botUserName)
                {
                    string uname = m.replyOrigMessage.Substring(19);
                    uname = uname.Substring(0, uname.IndexOf(" have?"));
                    DateTime birthday;
                    bool success = DateTime.TryParse(m.text_msg, out birthday);
                    if (success)
                    {
                        mod_birthday_birthday data = new mod_birthday_birthday(uname, birthday);
                        addBirthday(data, c);
                    }
                    else
                    {
                        Console.WriteLine("Failed to add birthday");
                        TelegramAPI.SendMessage(m.chatID, "Failed to add birthday");
                    }
                    processed = true;
                }

                else if (m.isReply && m.replyOrigMessage == "Whose birthday do you want to remove?" && m.replyOrigUser == Roboto.Settings.botUserName)
                {

                    bool success = removeBirthday(m.text_msg, c);
                    TelegramAPI.SendMessage(m.chatID, "Removed birthday for " + m.text_msg + " " + (success ? "successfully" : "but fell on my ass"));
                    processed = true;
                }
            }
            return processed;
        }
Ejemplo n.º 2
0
        public bool removeBirthday(string name, chat c)
        {
            mod_birthday_data     localData = c.getPluginData <mod_birthday_data>();
            mod_birthday_birthday birthday  = null;

            foreach (mod_birthday_birthday item in localData.birthdays)
            {
                if (item.name == name)
                {
                    birthday = item;
                }
            }
            if (birthday != null)
            {
                return(localData.birthdays.Remove(birthday));
            }
            return(false);
        }
Ejemplo n.º 3
0
        public override bool replyReceived(ExpectedReply e, message m, bool messageFailed = false)
        {
            chat c = Roboto.Settings.getChat(e.chatID);
            mod_birthday_data chatData = c.getPluginData <mod_birthday_data>();

            if (e.messageData == "ADD")
            {
                //reply to add word
                TelegramAPI.GetExpectedReply(e.chatID, m.userID, "What is their Birthday? (DD-MON-YYYY format, e.g. 01-JAN-1900)", true, this.GetType(), "ADD2-" + m.text_msg);
                return(true);
            }

            else if (e.messageData.StartsWith("ADD2"))
            {
                string   uname = e.messageData.Substring(5);
                DateTime birthday;
                bool     success = DateTime.TryParse(m.text_msg, out birthday);
                if (success)
                {
                    mod_birthday_birthday data = new mod_birthday_birthday(uname, birthday);
                    addBirthday(data, c);
                    TelegramAPI.SendMessage(e.chatID, "Added " + uname + "'s Birthday (" + birthday.ToString("yyyy-MM-dd") + ")");
                }
                else
                {
                    Console.WriteLine("Failed to add birthday");
                    TelegramAPI.SendMessage(m.chatID, "Failed to add birthday");
                }
                return(true);
            }

            else if (e.messageData == "REMOVE")
            {
                bool success = removeBirthday(m.text_msg, c);
                TelegramAPI.SendMessage(m.chatID, "Removed birthday for " + m.text_msg + " " + (success ? "successfully" : "but fell on my ass"));
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
 public void addBirthday(mod_birthday_birthday birthday, chat c)
 {
     mod_birthday_data localData = c.getPluginData<mod_birthday_data>();
     localData.birthdays.Add(birthday);
 }
Ejemplo n.º 5
0
        public void addBirthday(mod_birthday_birthday birthday, chat c)
        {
            mod_birthday_data localData = c.getPluginData <mod_birthday_data>();

            localData.birthdays.Add(birthday);
        }
Ejemplo n.º 6
0
        public override bool replyReceived(ExpectedReply e, message m, bool messageFailed = false)
        {
            chat c = Roboto.Settings.getChat(e.chatID);
            mod_birthday_data chatData = c.getPluginData<mod_birthday_data>();

            if (e.messageData == "ADD")
            {
                //reply to add word
                TelegramAPI.GetExpectedReply(e.chatID, m.userID, "What is their Birthday? (DD-MON-YYYY format, e.g. 01-JAN-1900)", true, this.GetType(), "ADD2-" + m.text_msg);
                return true;
            }

            else if (e.messageData.StartsWith("ADD2"))
            {
                string uname = e.messageData.Substring(5);
                DateTime birthday;
                bool success = DateTime.TryParse(m.text_msg, out birthday);
                if (success)
                {
                    mod_birthday_birthday data = new mod_birthday_birthday(uname, birthday);
                    addBirthday(data, c );
                    TelegramAPI.SendMessage(e.chatID, "Added " + uname + "'s Birthday (" + birthday.ToString("yyyy-MM-dd") + ")");
                }
                else
                {
                    Console.WriteLine("Failed to add birthday");
                    TelegramAPI.SendMessage(m.chatID, "Failed to add birthday");
                }
                return true;
            }

            else if (e.messageData == "REMOVE")
            {

                bool success = removeBirthday(m.text_msg, c);
                TelegramAPI.SendMessage(m.chatID, "Removed birthday for " + m.text_msg + " " + (success ? "successfully" : "but fell on my ass"));
                return true;
            }
            return false;
        }