void Bot_OnMessage(Network n, Irc.IrcEventArgs e) { if (IsMatch("^autoop \\?$", e.Data.Message)) { AnswerWithNotice(n, e, FormatBold("Use of AutoOp plugin:")); AnswerWithNotice(n, e, "No remote commands available. All configuration has to be done manually in the Configuration.xml."); } }
void Bot_OnMessage(Network n, Irc.IrcEventArgs e) { if (IsMatch("^log \\?$", e.Data.Message)) { AnswerWithNotice(n, e, FormatBold("Use of Log plugin:")); AnswerWithNotice(n, e, "No remote commands available. Every IRC command gets logged in its raw form to a file in the \\Data subdirectory."); } }
void Bot_OnRawMessage(Network network, Irc.IrcEventArgs e) { DateTime d = DateTime.Now; System.IO.StreamWriter writer = new System.IO.StreamWriter("Logs\\" + d.Year + "." + d.Month + "." + d.Day + ".log", true); writer.WriteLine(((TimeSpan)(DateTime.Now - new DateTime(1970, 1, 1))).TotalMilliseconds.ToString() + " " + e.Data.RawMessage); writer.Close(); }
void Bot_OnMessage(Network n, Irc.IrcEventArgs e) { if (IsMatch("^Eightball \\?$", e.Data.Message)) { AnswerWithNotice(n, e, FormatBold("Use of Eightball plugin:")); AnswerWithNotice(n, e, FormatItalic("<Botname> <your question, at least 7 characters long>?") + " - The bot will answer."); } else if (IsMatch("^" + n.Nickname + " .{7,}\\?\\s*$", e.Data.Message)) { Answer(n, e, answers[r.Next(answers.Length)] + ", " + e.Data.Nick + "."); } }
void Bot_OnMessage(Network n, Irc.IrcEventArgs e) { if (IsMatch("^googlesearch \\?$", e.Data.Message)) { AnswerWithNotice(n, e, FormatBold("Use of GoogleSearch plugin:")); AnswerWithNotice(n, e, FormatItalic("google <search term>") + " - Searches google for <search term> and lists the first two results."); AnswerWithNotice(n, e, FormatItalic("google <number of results> <search term>") + " - Searches google for <search term> and lists the first <number of results> (maximum is 10) results."); } else if (IsMatch("^google ((?<count>\\d{1,2}) )?(?<term>.*)$", e.Data.Message)) { int count = 2; if (Matches["count"].Length > 0) { count = int.Parse(Matches["count"].ToString()); } if (count > 10) { count = 10; } try { Google.Google.GoogleSearchService s = new Google.Google.GoogleSearchService(); Google.Google.GoogleSearchResult results = s.doGoogleSearch(Bot.Configuration["Plugins"]["GoogleSearch"].Attributes["Key"].Value, Matches["term"].ToString(), 0, count, false, "", false, "", "", ""); if (count > results.resultElements.Length) { count = results.resultElements.Length; } if (count > 0) { Answer(n, e, FormatBold(count.ToString() + " results for " + FormatItalic(Matches["term"].ToString()) + ".")); for (int i = 0; i < count; i++) { string result = results.resultElements[i].URL + " (" + FormatBold(results.resultElements[i].title) + " - " + results.resultElements[i].snippet + ")"; result = result.Replace("<b>", "").Replace("</b>", "").Replace("<br>", "").Replace("'", "'").Replace("&", "&"); Answer(n, e, result); } } else { Answer(n, e, "No results found for " + FormatItalic(Matches["term"].ToString()) + "."); } } catch (Exception ex) { Answer(n, e, "Error in GoogleSearch plugin: " + FormatItalic(ex.Message)); } } }
void Bot_OnMessage(Network network, Irc.IrcEventArgs e) { if (IsMatch("^bash \\?$", e.Data.Message)) { AnswerWithNotice(n, e, FormatBold("Use of Bash plugin:")); AnswerWithNotice(n, e, FormatItalic("bash") + " - Prints a random quote from http://www.bash.org."); } else if (IsMatch("^bash$", e.Data.Message)) { this.n = network; this.e = e; new System.Threading.Thread(new ThreadStart(GetBash)).Start(); } else if (IsMatch("^german bash$", e.Data.Message)) { this.n = network; this.e = e; new System.Threading.Thread(new ThreadStart(GetGermanBash)).Start(); } }
void Bot_OnMessage(Network network, Irc.IrcEventArgs e) { if (IsMatch("^reminder \\?$", e.Data.Message)) { AnswerWithNotice(network, e, FormatBold("Use of Reminder plugin:")); AnswerWithNotice(network, e, FormatItalic("remind me in <minutes> <message>") + " - Reminds you in <minutes> minutes."); AnswerWithNotice(network, e, FormatItalic("remind me at <hours>:<minutes> <message>") + " - Reminds you at the given time."); } else if (IsMatch("^remind me in (?<minutes>\\d{1,3}) (?<message>.*)$", e.Data.Message)) { List <RemindInfo> l = LoadFromFile <List <RemindInfo> >("Reminders"); RemindInfo i = new RemindInfo(); i.Network = network.Name; i.Channel = e.Data.Channel; i.User = e.Data.Nick; i.Message = Matches["message"].ToString(); i.Date = DateTime.Now.AddMinutes(int.Parse(Matches["minutes"].ToString())); i.IsPrivate = e.Data.Type == Irc.ReceiveType.QueryMessage; l.Add(i); SaveToFile <List <RemindInfo> >(l, "Reminders"); StartThread(); AnswerWithNotice(network, e, "You will be reminded."); } else if (IsMatch("^remind me at (?<hours>\\d{1,2}):(?<minutes>\\d{1,2}) (?<message>.*)$", e.Data.Message)) { List <RemindInfo> l = LoadFromFile <List <RemindInfo> >("Reminders"); RemindInfo i = new RemindInfo(); i.Network = network.Name; i.Channel = e.Data.Channel; i.User = e.Data.Nick; i.Message = Matches["message"].ToString(); i.Date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, int.Parse(Matches["hours"].ToString()), int.Parse(Matches["minutes"].ToString()), 0); if (i.Date < DateTime.Now) { i.Date = i.Date.AddDays(1); } i.IsPrivate = e.Data.Type == Irc.ReceiveType.QueryMessage; l.Add(i); SaveToFile <List <RemindInfo> >(l, "Reminders"); StartThread(); AnswerWithNotice(network, e, "You will be reminded."); } }
void GetGermanBash() { Network n = this.n; Irc.IrcEventArgs e = this.e; HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create("http://german-bash.org/action/random/n/1"); httpReq.Method = "GET"; WebResponse httpRes = httpReq.GetResponse(); StreamReader stream = new StreamReader(httpRes.GetResponseStream()); string responseString = stream.ReadToEnd(); stream.Close(); httpRes.Close(); Regex r = new Regex("\\<div class=\"zitat\"\\>(?<text>.*?)\\</div\\>", RegexOptions.Singleline); string text = r.Match(responseString).Groups["text"].ToString(); r = new Regex("\\<a name=\"(?<number>\\d*)\"\\>\\</a\\>"); string number = r.Match(responseString).Groups["number"].ToString(); text = text.Replace("<", "<"); text = text.Replace(">", ">"); text = text.Replace(""", "\""); text = text.Replace("<br />", "\r\n"); text = text.Replace(" ", " "); text = text.Replace("ü", "ü"); text = text.Replace("ä", "ä"); text = text.Replace("ö", "ö"); text = text.Replace("\r", ""); text = text.Replace("\t", ""); text = text.Trim(); Answer(n, e, FormatBold("german-bash.org quote #" + number)); foreach (string s in text.Split('\n')) { if (s.Length > 0) { Answer(n, e, s); } } }
void Bot_OnMessage(Network network, Irc.IrcEventArgs e) { if (IsMatch("^tell \\?$", e.Data.Message)) { AnswerWithNotice(network, e, FormatBold("Use of Tell plugin:")); AnswerWithNotice(network, e, FormatItalic("tell <recipient> <message>") + " - Tells <recipient> the <message> the next time he joins."); } else if (IsMatch("^tell (?<target>.*?) (?<message>.*)$", e.Data.Message)) { List <TellInfo> l = LoadFromFile <List <TellInfo> >("Tell"); TellInfo t = new TellInfo(); t.Date = DateTime.Now; t.Name = e.Data.Nick; t.Network = network.Name; t.Target = Matches["target"].ToString(); t.Text = Matches["message"].ToString(); l.Add(t); SaveToFile <List <TellInfo> >(l, "Tell"); AnswerWithNotice(network, e, "I'll tell your message."); } }
void Bot_OnMessage(Network network, Irc.IrcEventArgs e) { if (IsMatch("^bash \\?$", e.Data.Message)) { AnswerWithNotice(n, e, FormatBold("Use of Bash plugin:")); AnswerWithNotice(n, e, FormatItalic("bash") + " - Prints a random quote from http://www.bash.org."); AnswerWithNotice(n, e, FormatItalic("german bash") + " - Prints a random quote from http://www.german-bash.org."); } else if (IsMatch("^bash$", e.Data.Message)) { this.n = network; this.e = e; new System.Threading.Thread(new ThreadStart(GetBash)).Start(); } else if (IsMatch("^german bash$", e.Data.Message)) { this.n = network; this.e = e; new System.Threading.Thread(new ThreadStart(GetGermanBash)).Start(); } }
void Bot_OnMessage(Network network, Irc.IrcEventArgs e) { if (IsMatch("^seen \\?$", e.Data.Message)) { AnswerWithNotice(network, e, FormatBold("Use of Seen plugin:")); AnswerWithNotice(network, e, FormatItalic("seen <nick>") + " - Displays information when the Bot last saw <nick>."); } else if (IsMatch("^seen (?<nick>.*)$", e.Data.Message)) { SeenInfo i = FindName(network.Name, Matches["nick"].ToString(), l); if (i == null) { Answer(network, e, "I never saw " + Matches["nick"].ToString() + " before."); } else if (i.Ident == e.Data.Ident) { Answer(network, e, "Looking for yourself, eh?"); } else { string hour = "hours"; string minute = "minutes"; TimeSpan t = (TimeSpan)(DateTime.Now - i.Date); if (t.TotalHours == 1) { hour = "hour"; } if (t.Minutes == 1) { minute = "minute"; } Answer(network, e, "I saw " + Matches["nick"].ToString() + " " + Convert.ToInt16(t.TotalHours).ToString() + " " + hour + " and " + t.Minutes.ToString() + " " + minute + " ago, " + i.Text + "."); } } NewSeen(network.Name, e.Data.Nick, e.Data.Ident, "on " + e.Data.Channel + ", saying " + e.Data.Message); }
void GetBash() { Network n = this.n; Irc.IrcEventArgs e = this.e; HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create("http://bash.org/?random"); httpReq.Method = "GET"; WebResponse httpRes = httpReq.GetResponse(); StreamReader stream = new StreamReader(httpRes.GetResponseStream()); string responseString = stream.ReadToEnd(); stream.Close(); httpRes.Close(); int start = Regex.Match(responseString, "class=\"qt\"").Index + 11; int end = Regex.Match(responseString, "</p>\n<p class=\"quote\">").Index; string cutstring = responseString.Substring(start, end - start); cutstring = cutstring.Replace("<", "<"); cutstring = cutstring.Replace(">", ">"); cutstring = cutstring.Replace(""", "\""); cutstring = cutstring.Replace("<br />", "\r\n"); cutstring = cutstring.Replace(" ", " "); cutstring = cutstring.Replace("\r", ""); Match m = Regex.Match(responseString, "<a href=\".([0-9]{2,10})\" title"); Answer(n, e, FormatBold("bash.org quote #" + m.Groups[1].Value)); foreach (string s in cutstring.Split('\n')) { if (s.Length > 0) { Answer(n, e, s); } } }
void Bot_OnMessage(Network n, Irc.IrcEventArgs e) { if (IsMatch("^events \\?$", e.Data.Message)) { AnswerWithNotice(n, e, FormatBold("Use of Events plugin:")); AnswerWithNotice(n, e, FormatItalic("list events") + " - Lists details of all upcoming events."); AnswerWithNotice(n, e, FormatItalic("add <nick> to [<number>]") + " - Adds <nick> as there to the specified event (You may use 'me' instead of <nick>)."); AnswerWithNotice(n, e, FormatItalic("add <nick> not to [<number>]") + " - Adds <nick> as not there to the specified event (You may use 'me' instead of <nick>)."); AnswerWithNotice(n, e, FormatItalic("add <nick> maybe to [<number>]") + " - Adds <nick> as maybe there to the specified event (You may use 'me' instead of <nick>)."); AnswerWithNotice(n, e, FormatItalic("remove <nick> from [<number>]") + " - Removes <nick> from the specified event (You may use 'me' instead of <nick>)."); AnswerWithNotice(n, e, FormatItalic("add event <day>.<month>.<year> <hours>:<minutes> <text>") + " - Adds the specified event."); AnswerWithNotice(n, e, FormatItalic("edit event [<number>] <day>.<month>.<year> <hours>:<minutes> <text>") + " - Edits the specified event, but leaves the there/not there/maybe there nicknames intact."); AnswerWithNotice(n, e, FormatItalic("remove event [<number>]") + " - Removes the entire specified event."); AnswerWithNotice(n, e, FormatItalic("clear event [<number>]") + " - Removes all the there/not there/maybe there nicknames from the specified event, but leaves the event itself intact."); } else if (IsMatch("^list events$", e.Data.Message)) { List <EventInfo> eventInfos = LoadFromFile <List <EventInfo> >("Events"); DeleteOldEvents(eventInfos); int i = 0; foreach (EventInfo eventinfo in eventInfos) { string there = ""; foreach (string s in eventinfo.There) { there += s + ", "; } if (there.Length > 0) { there = there.Substring(0, there.Length - 2); } string maybeThere = ""; foreach (string s in eventinfo.MaybeThere) { maybeThere += s + ", "; } if (maybeThere.Length > 0) { maybeThere = maybeThere.Substring(0, maybeThere.Length - 2); } string notThere = ""; foreach (string s in eventinfo.NotThere) { notThere += s + ", "; } if (notThere.Length > 0) { notThere = notThere.Substring(0, notThere.Length - 2); } AnswerWithNotice(n, e, FormatBold("[" + Format(i) + "]") + " - " + FormatBold(eventinfo.Text) + " - scheduled for " + eventinfo.Date.ToLongDateString() + " " + eventinfo.Date.ToShortTimeString()); AnswerWithNotice(n, e, "there: " + FormatItalic(there) + " - maybe there: " + FormatItalic(maybeThere) + " - not there: " + FormatItalic(notThere)); i++; } if (i <= 0) { AnswerWithNotice(n, e, "There are no upcoming events."); } return; } else if (IsMatch("^add event (?<day>\\d{1,2})\\.(?<month>\\d{1,2})\\.(?<year>\\d{4}) (?<hour>\\d{1,2}):(?<minute>\\d{1,2}) (?<text>.*)$", e.Data.Message)) { DateTime d = new DateTime(int.Parse(Matches["year"].ToString()), int.Parse(Matches["month"].ToString()), int.Parse(Matches["day"].ToString()), int.Parse(Matches["hour"].ToString()), int.Parse(Matches["minute"].ToString()), 0); List <EventInfo> eventInfos = LoadFromFile <List <EventInfo> >("Events"); eventInfos.Add(new EventInfo(d, Matches["text"].ToString())); eventInfos.Sort(new EventInfoComparer()); SaveToFile <List <EventInfo> >(eventInfos, "Events"); AnswerWithNotice(n, e, "I added the event."); return; } else if (IsMatch("^add (?<nick>\\w*) to \\[(?<event>\\d{1,3})\\]$", e.Data.Message)) { List <EventInfo> eventInfos = LoadFromFile <List <EventInfo> >("Events"); int i = int.Parse(Matches["event"].ToString()); if (i >= eventInfos.Count) { AnswerWithNotice(n, e, "There is no such event."); return; } EventInfo eventinfo = eventInfos[i]; string nick = Matches["nick"].ToString(); if (nick.ToLower() == "me") { nick = e.Data.Nick; } Remove(nick, eventinfo); eventinfo.There.Add(nick); eventInfos.Sort(new EventInfoComparer()); SaveToFile <List <EventInfo> >(eventInfos, "Events"); AnswerWithNotice(n, e, "I added " + FormatItalic(nick) + " as " + FormatItalic("there") + "."); return; } else if (IsMatch("^add (?<nick>\\w*) not to \\[(?<event>\\d{1,3})\\]$", e.Data.Message)) { List <EventInfo> eventInfos = LoadFromFile <List <EventInfo> >("Events"); int i = int.Parse(Matches["event"].ToString()); if (i >= eventInfos.Count) { AnswerWithNotice(n, e, "There is no such event."); return; } EventInfo eventinfo = eventInfos[i]; string nick = Matches["nick"].ToString(); if (nick.ToLower() == "me") { nick = e.Data.Nick; } Remove(nick, eventinfo); eventinfo.NotThere.Add(nick); eventInfos.Sort(new EventInfoComparer()); SaveToFile <List <EventInfo> >(eventInfos, "Events"); AnswerWithNotice(n, e, "I added " + FormatItalic(nick) + " as " + FormatItalic("not there") + "."); return; } else if (IsMatch("^add (?<nick>\\w*) maybe to \\[(?<event>\\d{1,3})\\]$", e.Data.Message)) { List <EventInfo> eventInfos = LoadFromFile <List <EventInfo> >("Events"); int i = int.Parse(Matches["event"].ToString()); if (i >= eventInfos.Count) { AnswerWithNotice(n, e, "There is no such event."); return; } EventInfo eventinfo = eventInfos[i]; string nick = Matches["nick"].ToString(); if (nick.ToLower() == "me") { nick = e.Data.Nick; } Remove(nick, eventinfo); eventinfo.MaybeThere.Add(nick); eventInfos.Sort(new EventInfoComparer()); SaveToFile <List <EventInfo> >(eventInfos, "Events"); AnswerWithNotice(n, e, "I added " + FormatItalic(nick) + " as " + FormatItalic("maybe there") + "."); return; } else if (IsMatch("^remove (?<nick>\\w*) from \\[(?<event>\\d{1,3})\\]$", e.Data.Message)) { string nick = Matches["nick"].ToString(); if (nick.ToLower() == "me") { nick = e.Data.Nick; } List <EventInfo> eventInfos = LoadFromFile <List <EventInfo> >("Events"); int i = int.Parse(Matches["event"].ToString()); if (i >= eventInfos.Count) { AnswerWithNotice(n, e, "There is no such event."); return; } Remove(nick, eventInfos[i]); eventInfos.Sort(new EventInfoComparer()); SaveToFile <List <EventInfo> >(eventInfos, "Events"); AnswerWithNotice(n, e, "I removed " + FormatItalic(nick) + "."); return; } else if (IsMatch("^remove event \\[(?<event>\\d{1,3})\\]$", e.Data.Message)) { List <EventInfo> eventInfos = LoadFromFile <List <EventInfo> >("Events"); int i = int.Parse(Matches["event"].ToString()); if (i >= eventInfos.Count) { AnswerWithNotice(n, e, "There is no such event."); return; } eventInfos.RemoveAt(i); eventInfos.Sort(new EventInfoComparer()); SaveToFile <List <EventInfo> >(eventInfos, "Events"); AnswerWithNotice(n, e, "I removed the event."); return; } else if (IsMatch("^clear event \\[(?<event>\\d{1,3})\\]$", e.Data.Message)) { List <EventInfo> eventInfos = LoadFromFile <List <EventInfo> >("Events"); int i = int.Parse(Matches["event"].ToString()); if (i >= eventInfos.Count) { AnswerWithNotice(n, e, "There is no such event."); return; } EventInfo eventinfo = eventInfos[i]; eventinfo.There.Clear(); eventinfo.MaybeThere.Clear(); eventinfo.NotThere.Clear(); eventInfos.Sort(new EventInfoComparer()); SaveToFile <List <EventInfo> >(eventInfos, "Events"); AnswerWithNotice(n, e, "I cleared the event."); return; } else if (IsMatch("^edit event \\[(?<event>\\d{1,3})\\] (?<day>\\d{1,2})\\.(?<month>\\d{1,2})\\.(?<year>\\d{4}) (?<hour>\\d{1,2}):(?<minute>\\d{1,2}) (?<text>.*)$", e.Data.Message)) { List <EventInfo> eventInfos = LoadFromFile <List <EventInfo> >("Events"); int i = int.Parse(Matches["event"].ToString()); if (i >= eventInfos.Count) { AnswerWithNotice(n, e, "There is no such event."); return; } EventInfo eventinfo = eventInfos[i]; DateTime d = new DateTime(int.Parse(Matches["year"].ToString()), int.Parse(Matches["month"].ToString()), int.Parse(Matches["day"].ToString()), int.Parse(Matches["hour"].ToString()), int.Parse(Matches["minute"].ToString()), 0); eventinfo.Date = d; eventinfo.Text = Matches["text"].ToString(); eventInfos.Sort(new EventInfoComparer()); SaveToFile <List <EventInfo> >(eventInfos, "Events"); AnswerWithNotice(n, e, "I edited the event."); return; } }
void Bot_OnMessage(Network n, Irc.IrcEventArgs e) { if (IsMatch("^quote \\?$", e.Data.Message)) { AnswerWithNotice(n, e, FormatBold("Use of Quote plugin:")); AnswerWithNotice(n, e, FormatItalic("quote") + " - Prints a random quote."); AnswerWithNotice(n, e, FormatItalic("quote <name>") + " - Prints a random quote from <name>."); AnswerWithNotice(n, e, FormatItalic("quote <name> [<number>]") + " - Prints the specified quote from <name>."); AnswerWithNotice(n, e, FormatItalic("add quote from <name> <quote>") + " - Adds the a quote from <name>."); AnswerWithNotice(n, e, FormatItalic("list quotes") + " - Lists the sources of all quotes."); AnswerWithNotice(n, e, FormatItalic("list quotes from <name>") + " - Lists all quotes of <name>."); AnswerWithNotice(n, e, FormatItalic("remove quote [<number>] from <name>") + " - Removes the specified quote from <name>."); AnswerWithNotice(n, e, FormatItalic("edit quote [<number>] from <name> <new quote>") + " - Changes the specified quote from <name> to <new quote>."); } else if (IsMatch("^quote$", e.Data.Message)) { string quote = GetQuote(LoadFromFile <List <QuoteInfo> >("Quotes")); if (quote.Length > 0) { Answer(n, e, quote); } else { AnswerWithNotice(n, e, "I'm sorry, but I don't know any quotes."); } } else if (IsMatch("^quote (?<type>\\w*)$", e.Data.Message)) { string quote = GetQuote(Matches["type"].ToString(), LoadFromFile <List <QuoteInfo> >("Quotes")); if (quote.Length > 0) { Answer(n, e, quote); } else { AnswerWithNotice(n, e, "I'm sorry, but I don't know any quotes from " + FormatItalic(Matches["type"].ToString()) + "."); } } else if (IsMatch("^quote (?<type>\\w*?) \\[(?<number>\\d{1,2})\\]$", e.Data.Message)) { List <QuoteInfo> quotes = GetQuotes(Matches["type"].ToString(), LoadFromFile <List <QuoteInfo> >("Quotes")); int i = int.Parse(Matches["number"].ToString()); if (quotes.Count >= i + 1) { Answer(n, e, quotes[i].Text); } else { AnswerWithNotice(n, e, "I'm sorry, but this quote does not exist."); } } else if (IsMatch("^add quote from (?<type>\\w*?) (?<text>.*)$", e.Data.Message)) { List <QuoteInfo> quotes = LoadFromFile <List <QuoteInfo> >("Quotes"); quotes.Add(new QuoteInfo(Matches["type"].ToString(), Matches["text"].ToString())); SaveToFile <List <QuoteInfo> >(quotes, "Quotes"); AnswerWithNotice(n, e, "I added this quote from " + FormatItalic(Matches["type"].ToString()) + "."); } else if (IsMatch("^list quotes$", e.Data.Message)) { List <QuoteInfo> quotes = LoadFromFile <List <QuoteInfo> >("Quotes"); if (quotes.Count > 0) { List <string> names = new List <string>(); foreach (QuoteInfo q in quotes) { if (!names.Contains(q.Type.ToLower())) { names.Add(q.Type.ToLower()); } } AnswerWithNotice(n, e, FormatBold("The sources of all quotes:")); foreach (string s in names) { AnswerWithNotice(n, e, s); } } else { AnswerWithNotice(n, e, "I'm sorry, but I don't know any quotes."); } } else if (IsMatch("^list quotes from (?<type>\\w*?)$", e.Data.Message)) { List <QuoteInfo> quotes = GetQuotes(Matches["type"].ToString(), LoadFromFile <List <QuoteInfo> >("Quotes")); if (quotes.Count > 0) { AnswerWithNotice(n, e, FormatBold("All Quotes from " + FormatItalic(Matches["type"].ToString()) + ":")); for (int i = 0; i < quotes.Count; i++) { AnswerWithNotice(n, e, FormatBold("[" + Format(i) + "]") + " " + quotes[i].Text); } } else { AnswerWithNotice(n, e, "I'm sorry, but I don't know any quotes from " + FormatItalic(Matches["type"].ToString()) + "."); } } else if (IsMatch("^remove quote \\[(?<number>\\d{1,3})\\] from (?<type>\\w*?)$", e.Data.Message)) { List <QuoteInfo> allQuotes = LoadFromFile <List <QuoteInfo> >("Quotes"); List <QuoteInfo> quotes = GetQuotes(Matches["type"].ToString(), allQuotes); int i = int.Parse(Matches["number"].ToString()); if (quotes.Count >= i + 1) { allQuotes.Remove(quotes[i]); SaveToFile <List <QuoteInfo> >(quotes, "Quotes"); AnswerWithNotice(n, e, "I removed this quote from " + FormatItalic(Matches["type"].ToString()) + "."); } else { AnswerWithNotice(n, e, "I'm sorry, but this quote does not exist."); } } else if (IsMatch("^edit quote \\[(?<number>\\d{1,3})\\] from (?<type>\\w*?) (?<text>.*)$", e.Data.Message)) { List <QuoteInfo> allQuotes = LoadFromFile <List <QuoteInfo> >("Quotes"); List <QuoteInfo> quotes = GetQuotes(Matches["type"].ToString(), allQuotes); int i = int.Parse(Matches["number"].ToString()); if (quotes.Count >= i + 1) { quotes[i].Text = Matches["text"].ToString(); SaveToFile <List <QuoteInfo> >(quotes, "Quotes"); AnswerWithNotice(n, e, "I edited this quote from " + FormatItalic(Matches["type"].ToString()) + "."); } else { AnswerWithNotice(n, e, "I'm sorry, but this quote does not exist."); } } }