private void bot_OnPublicMessage(User user, string channel, string message) { try { if ( !message.StartsWith("!") ) { #region wordstat string[] parts = message.Split(' '); foreach (string part in parts) { wordstat.Increment(channel, part); // bedre med en rigtig for-løkke userstatw.Increment(channel,user.NickName); } #endregion #region userstat userstat.Increment(channel, user.NickName); // tæl linjer. evt en wordcol også #endregion } else if (message == "!topwords") //eller toptalk{ { log.Info("Listing top words on "+channel+"..."); if (!wordstat.Contains(channel)) { bot.SendToChannel(channel, "No stats yet ...", true); return; } string output = ""; StatCollection scol = wordstat[channel].GetTop(10); int topCount = scol.Count>10?10:scol.Count; for (int i=0; i<topCount; i++) { output += "\u0002"+(i+1)+"\u0002 - ["+scol[i].Key+"]: "+scol[i].Score+"; "; } bot.SendToChannel(channel, output, true); } else if (message == "!toptalk") { log.Info("Listing top talkers on "+channel+"..."); string output = ""; if (!userstatw.Contains(channel)) { bot.SendToChannel(channel, "No stats yet ...", true); return; } StatCollection scol = userstatw[channel].GetTop(10); int topCount = scol.Count>10?10:scol.Count; for (int i=0; i<topCount; i++) { output += "\u0002"+(i+1)+"\u0002 - ["+scol[i].Key+"]: "+scol[i].Score+"; "; } bot.SendToChannel(channel, output, true); } else if (message == "!toplines") { log.Info("Listing top talkers on "+channel+"..."); string output = ""; if (!userstat.Contains(channel)) { bot.SendToChannel(channel, "No stats yet ...", true); return; } StatCollection scol = userstat[channel].GetTop(10); int topCount = scol.Count>10?10:scol.Count; for (int i=0; i<topCount; i++) { output += "\u0002"+(i+1)+"\u0002 - ["+scol[i].Key+"]: "+scol[i].Score+"; "; } bot.SendToChannel(channel, output, true); } else if (message=="!chanstat") { log.Info("Listing stat info"); if (!wordstat.Contains(channel)) { bot.SendToChannel(channel, "No stats yet ...", true); return; } int chncount = wordstat[channel].Count; bot.SendToChannel(channel, chncount+" words known in this channel", true); int count = 0; foreach (object okey in wordstat.Keys) { string key = okey as string; count += wordstat[key].Count; } if (count > chncount) bot.SendToChannel(channel, count+" words known in all channels", true); } else if (message=="!mystat") { log.Info("Listing personal stats info"); bot.SendToChannel(channel, "You seem to know an astonishing "+userstat[channel][user.NickName].Score+" words ..."); } } catch (Exception e) { log.Error("Error in statplugin.onpublicmessage('"+user.NickName+"','"+channel+"', '"+message+"')",e); } }
private void bot_OnPrivateMessage(User user, string channel, string message) { if (message == "!colortest") { bot.SendToUser(user.NickName, "I am ^C4,7really upset^C at my brother for ^C0,1WASTING ^C15,000 sheets of paper!"); bot.SendToUser(user.NickName, "dette er en \u0020Bold\u0020 test"); bot.SendToUser(user.NickName, "dette er en \u0002Bold\u0002 test 2"); } }
private void bot_OnPublicAction(User user, string channel, string message) { // public action WriteToFile(channel, "* "+user.Name+" "+message); }
void bot_OnPrivateMessage( User user, string channel, string message ) { if (message.StartsWith("!startvote")) { if (!reflist.ContainsKey(user.NickName)) { reflist.Add(user.NickName, new Referendum(user.NickName, bot)); // opret i liste hvis den ikke er der reflist[user.NickName].StartWizard(); } else { //der er allerede en igang bot.SendToUser(user.NickName, "another vote is running, please wait"); } return; } if ( message.StartsWith( "!vote " ) ) { reflist[user.NickName].AcceptVote(user.NickName, message); } else if ( reflist.ContainsKey( user.NickName ) ) { reflist[user.NickName].ProcessMessage( message ); // hvis der er oprettet et ref på denne user, send besked videre} } }
/// <summary> /// Removes the specified user. /// </summary> /// <param name="user">The user.</param> public void Remove(User user) { List.Remove(user); }
/// <summary> /// Adds the specified user. /// </summary> /// <param name="user">The user.</param> public void Add(User user) { List.Add(user); }