Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void addBirthday(mod_birthday_birthday birthday, chat c)
        {
            mod_birthday_data localData = c.getPluginData <mod_birthday_data>();

            localData.birthdays.Add(birthday);
        }