public void Message(DateTime Timestamp, uint TimeframeID, Sender Sender, string PrivMsg)
 {
     ChannelFacts CurCF = GetChannelFactFromTimeframe(TimeframeID);
     CurCF.Messages++;
     Guid CurGuid = GetGuid(Sender);
     Users[CurGuid].AddMessage(Timestamp, TimeframeID, Sender, PrivMsg);
 }
 public void Mode(DateTime Timestamp, uint TimeframeID, Sender Sender, string ModeText)
 {
     ChannelFacts CurCF = GetChannelFactFromTimeframe(TimeframeID);
     CurCF.ModesSet++;
     Guid CurGuid = GetGuid(Sender);
     Users[CurGuid].AddMode(Timestamp, TimeframeID, Sender, ModeText);
 }
 public void Join(DateTime Timestamp, uint TimeframeID, Sender Sender)
 {
     ChannelFacts CurCF = GetChannelFactFromTimeframe(TimeframeID);
     CurCF.Joins++;
     Guid CurGuid = GetGuid(Sender);
     Users[CurGuid].AddJoin(Timestamp, TimeframeID, Sender);
 }
 public void Kick(DateTime Timestamp, uint TimeframeID, Sender Sender, string PersonKicked, string KickMsg)
 {
     ChannelFacts CurCF = GetChannelFactFromTimeframe(TimeframeID);
     CurCF.Kicks++;
     Guid CurGuid = GetGuid(Sender);
     Users[CurGuid].AddKick(Timestamp, TimeframeID, Sender, PersonKicked, KickMsg);
 }
 public void Action(DateTime Timestamp, uint TimeframeID, Sender Sender, string ActionMsg)
 {
     ChannelFacts CurCF = GetChannelFactFromTimeframe(TimeframeID);
     CurCF.Actions++;
     Guid CurGuid = GetGuid(Sender);
     Users[CurGuid].AddAction(Timestamp, TimeframeID, Sender, ActionMsg);
 }
 public static Sender ParseSender(string SenderStr)
 {
     Sender TmpSender = new Sender();
     TmpSender.SenderStr = SenderStr;
     if (SenderStr.Contains("!") && SenderStr.Contains("@")) {
         string[] TempSender = SenderStr.Split('!');
         TmpSender.Nick = TempSender[0];
         TempSender = TempSender[1].Split('@');
         TmpSender.Ident = TempSender[0];
         TmpSender.Host = TempSender[1];
     } else {
         TmpSender.Server = SenderStr;
     }
     return TmpSender;
 }
 public void AddMode(DateTime Timestamp, uint TimeframeID, Sender Sender, string ModeText)
 {
     RegisterSender(Timestamp, Sender);
     UserFacts CurUF = GetUserFactFromTimeframe(TimeframeID);
     CurUF.ModesSet++;
 }
 public void AddMessage(DateTime Timestamp, uint TimeframeID, Sender Sender, string PrivMsg)
 {
     RegisterSender(Timestamp, Sender);
     UserFacts CurUF = GetUserFactFromTimeframe(TimeframeID);
     CurUF.Messages++;
 }
 public void AddKick(DateTime Timestamp, uint TimeframeID, Sender Sender, string PersonKicked, string KickMsg)
 {
     RegisterSender(Timestamp, Sender);
     UserFacts CurUF = GetUserFactFromTimeframe(TimeframeID);
     CurUF.Kicks++;
 }
 public void AddJoin(DateTime Timestamp, uint TimeframeID, Sender Sender)
 {
     RegisterSender(Timestamp, Sender);
     UserFacts CurUF = GetUserFactFromTimeframe(TimeframeID);
     CurUF.Joins++;
 }
 public void AddAction(DateTime Timestamp, uint TimeframeID, Sender Sender, string ActionMsg)
 {
     RegisterSender(Timestamp, Sender);
     UserFacts CurUF = GetUserFactFromTimeframe(TimeframeID);
     CurUF.Actions++;
 }
 public void Quit(DateTime Timestamp, uint TimeframeID, Sender Sender, string QuitMsg)
 {
     ChannelFacts CurCF = GetChannelFactFromTimeframe(TimeframeID);
     CurCF.Quits++;
     Guid CurGuid = GetGuid(Sender);
     Users[CurGuid].AddQuit(Timestamp, TimeframeID, Sender, QuitMsg);
 }
 public void ChangeNick(DateTime Timestamp, uint TimeframeID, Sender Sender, string NewNick)
 {
     Sender NewSender = Sender;
     NewSender.Nick = NewNick;
     NewSender.SenderStr = NewSender.SenderStr.Replace(Sender.Nick + '!', NewNick + '!');
     RegisterSender(Timestamp, NewSender);
     UserFacts CurUF = GetUserFactFromTimeframe(TimeframeID);
     CurUF.NickChanges++;
 }
 private Guid GetGuid(Sender Sender)
 {
     // Will need to add logic for fuzzy matching nicks or something... hmmm.
     // This will definitely be one of the most important functions in the app.
     foreach (KeyValuePair<Guid, User> CurKVP in Users) {
         if (CurKVP.Value.SenderHistory.Count != 0) {
             if (CurKVP.Value.SenderHistory.Values.Last().SenderStr == Sender.SenderStr) {
                 return CurKVP.Key;
             }
         }
     }
     // If we're not returning a Guid already we can't find it, so create a user and return it's new Guid.
     Guid TempGuid = Guid.NewGuid();
     Users.Add(TempGuid, new User());
     return TempGuid;
 }
 public void Topic(DateTime Timestamp, uint TimeframeID, Sender Sender, string TopicText)
 {
     ChannelFacts CurCF = GetChannelFactFromTimeframe(TimeframeID);
     CurCF.TopicsSet++;
     Guid CurGuid = GetGuid(Sender);
     Users[CurGuid].AddTopic(Timestamp, TimeframeID, Sender, TopicText);
     // Don't add duplicate back-to-back TOPICs as they're likely just from rejoining.
     if (TopicHistory.Count > 0) { if (TopicHistory.Values.Last().Text == TopicText) { return; } }
     Topic Temp = new Topic();
     Temp.Changed = Timestamp;
     Temp.Sender = Sender;
     Temp.Text = TopicText;
     while (TopicHistory.ContainsKey(Timestamp)) { Timestamp = Timestamp.AddMilliseconds(1); }
     TopicHistory.Add(Timestamp, Temp);
 }
 public void AddQuit(DateTime Timestamp, uint TimeframeID, Sender Sender, string KickMsg)
 {
     RegisterSender(Timestamp, Sender);
     UserFacts CurUF = GetUserFactFromTimeframe(TimeframeID);
     CurUF.Quits++;
 }
 public void AddTopic(DateTime Timestamp, uint TimeframeID, Sender Sender, string TopicText)
 {
     RegisterSender(Timestamp, Sender);
     UserFacts CurUF = GetUserFactFromTimeframe(TimeframeID);
     CurUF.TopicsSet++;
 }
 public void Parse(DateTime Timestamp, uint TimeframeID, Sender Sender, string Command, string Parameters)
 {
     string[] ParamSplit = Parameters.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
     switch (Command.ToUpper()) {
         case "353":
             // 353 - RPL_NAMREPLY - "<channel> :[[@|+]<nick> [[@|+]<nick> [...]]]"
             for (int i = 0; i < ParamSplit.Length; i++) {
                 if (ParamSplit[i].Substring(0, 1) == "#") {
                     // Skip to where we see the channel name.
                     string Chan = ParamSplit[i].ToLower();
                     ParamSplit[i + 1] = ParamSplit[i + 1].Substring(1);
                     string[] NameArr = new string[ParamSplit.Length - i - 1];
                     Array.Copy(ParamSplit, i + 1, NameArr, 0, ParamSplit.Length - i - 1);
                     Channels[ParamSplit[i]].Names(NameArr);
                     break;
                 }
             }
             break;
         case "470":
             // Channel Forward
             // :adams.freenode.net 470 SomethingKewl #windows ##windows :Forwarding to another channel
             // Do we need to do anything here for stats? More code in IRCLogger.Server.Parse()
         case "JOIN":
             ParamSplit[0] = ParamSplit[0].ToLower();
             if (ParamSplit[0].Contains(":")) {
                 // Fix because some IRCds send "JOIN :#channel" instead of "JOIN #channel"
                 ParamSplit[0] = ParamSplit[0].Substring(1).ToLower();
             }
             Channels[ParamSplit[0]].Join(Timestamp, TimeframeID, Sender);
             break;
         case "PART":
             ParamSplit[0] = ParamSplit[0].ToLower();
             if (ParamSplit.Length >= 2) {
                 string PartMsg = Parameters.Substring(Parameters.IndexOf(":") + 1);
                 if (PartMsg.Length == 0) {
                     Channels[ParamSplit[0]].Part(Timestamp, TimeframeID, Sender, String.Empty);
                 } else {
                     if ((PartMsg.Substring(0, 1) == "\"") && (PartMsg.Substring(PartMsg.Length - 1, 1) == "\"")) {
                         PartMsg = PartMsg.Substring(1, PartMsg.Length - 2);
                     }
                 }
                 Channels[ParamSplit[0]].Part(Timestamp, TimeframeID, Sender, PartMsg);
             } else {
                 Channels[ParamSplit[0]].Part(Timestamp, TimeframeID, Sender, String.Empty);
             }
             break;
         case "KICK":
             ParamSplit[0] = ParamSplit[0].ToLower();
             Channels[ParamSplit[0]].Kick(Timestamp, TimeframeID, Sender, ParamSplit[1], Functions.CombineAfterIndex(ParamSplit, " ", 2).Substring(1));
             break;
         case "INVITE":
             // TODO: Not sure how we want to handle this.
             break;
         case "NICK":
             if (IRCFunctions.GetNickFromHostString(Sender.SenderStr) == m_Nick) {
                 m_Nick = Parameters.Substring(1);
             }
             foreach (KeyValuePair<string, Channel> CurKVP in Channels) {
                 Channels[CurKVP.Key].Nick(Timestamp, TimeframeID, Sender, Parameters.Substring(1));
             }
             break;
         case "QUIT":
             foreach (KeyValuePair<string, Channel> CurKVP in Channels) {
                 Channels[CurKVP.Key].Quit(Timestamp, TimeframeID, Sender, Parameters.Substring(1));
             }
             break;
         case "TOPIC":
             ParamSplit[0] = ParamSplit[0].ToLower();
             string Topic = Parameters.Substring(Parameters.IndexOf(":") + 1);
             Channels[ParamSplit[0]].Topic(Timestamp, TimeframeID, Sender, Topic);
             break;
         case "MODE":
             ParamSplit[0] = ParamSplit[0].ToLower();
             if (ParamSplit[0].Substring(0, 1) == "#") {
                 // Is a channel mode
                 Channels[ParamSplit[0]].Mode(Timestamp, TimeframeID, Sender, Functions.CombineAfterIndex(ParamSplit, " ", 1));
             } else {
                 // Is not going to a channel. Probably me?
             }
             break;
         case "PRIVMSG":
             ParamSplit[0] = ParamSplit[0].ToLower();
             string MsgText = Parameters.Substring(Parameters.IndexOf(":") + 1);
             if (ParamSplit[0].Substring(0, 1) == "#") {
                 // Is going to a channel
                 if (MsgText.Substring(0, 1) == "\x1") {
                     // If this is a special PRIVMSG, like an action or CTCP
                     MsgText = MsgText.Substring(1, MsgText.Length - 2);
                     string[] PrivMsgSplit = MsgText.Split(" ".ToCharArray(), 2);
                     switch (PrivMsgSplit[0].ToUpper()) {
                         case "ACTION":
                             Channels[ParamSplit[0]].Action(Timestamp, TimeframeID, Sender, PrivMsgSplit[1]);
                             break;
                         // Maybe other stuff goes here like channel wide CTCPs?
                     }
                 } else {
                     // If this is just a normal PRIVMSG.
                     Channels[ParamSplit[0]].Message(Timestamp, TimeframeID, Sender, MsgText);
                 }
             } else {
                 // Is not going to a channel. Probably just me?
                 if (MsgText.Substring(0, 1) == "\x1") {
                     // If this is a special PRIVMSG, like an action or CTCP
                     MsgText = MsgText.Substring(1, MsgText.Length - 2);
                     string[] PrivMsgSplit = MsgText.Split(" ".ToCharArray(), 2);
                     switch (PrivMsgSplit[0].ToUpper()) {
                         case "ACTION":
                             // Not sure what to do here...
                             break;
                         case "VERSION":
                             //Send(IRCFunctions.CTCPVersionReply(IRCFunctions.GetNickFromHostString(Sender)));
                             break;
                         case "TIME":
                             //Send(IRCFunctions.CTCPTimeReply(IRCFunctions.GetNickFromHostString(Sender)));
                             break;
                         case "PING":
                             //Send(IRCFunctions.CTCPPingReply(IRCFunctions.GetNickFromHostString(Sender), PrivMsgSplit[1]));
                             break;
                     }
                 } else {
                     // Private Message directly to me.
                     string[] MsgSplitPrv = MsgText.Split(" ".ToCharArray());
                     //BotCommands.HandlePM(Sender, MsgSplitPrv);
                 }
             }
             break;
         case "NOTICE":
             // Needed for NickServ stuff
             string[] MsgSplitNtc = Parameters.Substring(Parameters.IndexOf(":") + 1).Split(" ".ToCharArray());
             //BotCommands.HandleNotice(Sender, MsgSplitNtc);
             break;
     }
 }
 public void RegisterSender(DateTime Timestamp, Sender Sender)
 {
     // Good candidate for optimization
     if ((SenderHistory.Count == 0) || (SenderHistory.Values.Last().SenderStr != Sender.SenderStr)) {
         while (SenderHistory.ContainsKey(Timestamp)) {
             Timestamp = Timestamp.AddMilliseconds(1);
         }
         SenderHistory.Add(Timestamp, Sender);
     }
 }
 public void Nick(DateTime Timestamp, uint TimeframeID, Sender Sender, string NewNick)
 {
     ChannelFacts CurCF = GetChannelFactFromTimeframe(TimeframeID);
     CurCF.NickChanges++;
     Guid CurGuid = GetGuid(Sender);
     Users[CurGuid].ChangeNick(Timestamp, TimeframeID, Sender, NewNick);
 }