Beispiel #1
0
 protected override void OnChannelUserJoined(IrcChannel channel, IrcChannelUserEventArgs e)
 {
     if (Properties.Settings.Default.SilentMode.ToString() != "true")
     {
         if (xmlprovider == null)
         {
             xmlprovider = new XMLProvider();
         }
         ReconnectInbound = false;
         if (!e.ChannelUser.User.ToString().ToLower().Contains("andchat"))
         {
             #region whisperstatsonjoin
             NormalisedUser normaliseduser = new NormalisedUser();
             normaliseduser.orig_username = e.ChannelUser.User.ToString();
             IEnumerable<User> joineduser = LUserList.Where(x => x.isUser(normaliseduser.normalised_username()));
             if (joineduser.Count() > 0)
             {
                 Tuple<DateTime, int> VisitData = joineduser.First().visit();
                 string visitstring = "";
                 switch (VisitData.Item2)
                 {
                     case 1: visitstring = VisitData.Item2 + "st"; break;
                     case 2: visitstring = VisitData.Item2 + "nd"; break;
                     case 3: visitstring = VisitData.Item2 + "rd"; break;
                     default: visitstring = VisitData.Item2 + "th"; break;
                 }
                 String days_since_last_visit = DateTime.Now.Subtract(Convert.ToDateTime(VisitData.Item1)).ToString("d' days 'h':'mm':'ss");
                 String output = "This is " + normaliseduser.normalised_username() + "'s " + visitstring + " visit. Their last visit was on " + VisitData.Item1.ToString("dd-MM-yyyy HH:mm:ss") + " (" + days_since_last_visit + " ago)";
                 foreach (var loggingOp in LUserList.Where(x => x.bIsLoggingOp))
                     thisclient.LocalUser.SendNotice(loggingOp.Name, output);
             }
             else
             {
                 String output = "This is " + normaliseduser.normalised_username() + "'s first visit.";
                 foreach (var loggingOp in LUserList.Where(x => x.bIsLoggingOp))
                     thisclient.LocalUser.SendNotice(loggingOp.Name, output);
                 User newUser = new User();
                 XDocument Streams = XDocument.Load(Directory.GetCurrentDirectory() + "/XML/Streams.xml");
                 IEnumerable<XElement> streamchildren = from streams in Streams.Root.Elements() select streams;
                 foreach (var stream in streamchildren)
                 {
                     newUser.addStream(stream.Attribute("Channel").Value, true);
                 }
                 newUser.Name = normaliseduser.normalised_username();
                 newUser.bIsLoggingOp = false;
                 newUser.password = "";
                 newUser.bMessages = false;
                 newUser.visit();
                 LUserList.Add(newUser);
                 // TODO: Suscribe to all streams;
             }
             #endregion
             SaveUserList();
             foreach (string streamname in xmlprovider.OnlineStreamList())
             {
                 string _streamname = streamname.Replace(",", "");
                 User user = getUser(normaliseduser.normalised_username().ToLower());
                 if(user != null)
                 if (user.isSubscribed(_streamname))
                 {
                         thisclient.LocalUser.SendNotice(e.ChannelUser.User.ToString(), String.Format(
                                                     "Stream running: _{0}_ ({1}) at {2}",
                                                     _streamname,
                                                     xmlprovider.StreamInfo(_streamname, "game"),
                                                     xmlprovider.StreamInfo(_streamname, "URL")
                                                     ));
                 }
             }
             normaliseduser = null;
         }
     }
 }
Beispiel #2
0
 public User RemoveAlias(string aliasname)
 {
     IEnumerable<Alias> _Aliase = Aliase.Where(x => x.Name.ToLower() == aliasname.ToLower());
     if(_Aliase.Count()>0)
     {
         User RestoredUser = new User();
         RestoredUser.LastVisit = _Aliase.FirstOrDefault().LastVisitBackup;
         RestoredUser.Name = _Aliase.FirstOrDefault().Name;
         RestoredUser.VisitCounter = _Aliase.FirstOrDefault().VisitCounterBackup;
         Aliase.RemoveAll(x => x.Name.ToLower() == aliasname.ToLower());
         return RestoredUser;
     }
     else
     {
         return null;
     }
 }
Beispiel #3
0
        public void UmportUsers()
        {
            if (File.Exists(Directory.GetCurrentDirectory() + "/XML/Users.xml"))
            {
                XDocument Users = XDocument.Load(Directory.GetCurrentDirectory() + "/XML/Users.xml");
                IEnumerable<XElement> childlist = from users in Users.Root.Elements() select users;

                XDocument Streams = XDocument.Load(Directory.GetCurrentDirectory() + "/XML/Streams.xml");
                IEnumerable<XElement> streamchildren = from streams in Streams.Root.Elements() select streams;
                foreach (var user in childlist)
                {
                    User newuser = new User();
                    newuser.Name = user.Attribute("Nick").Value;
                    System.Diagnostics.Debug.WriteLine(user.Attribute("LastVisit").Value);
                    try
                    {
                        newuser.LastVisit = Convert.ToDateTime(user.Attribute("LastVisit").Value);
                    }catch (Exception)
                    {
                        newuser.LastVisit = DateTime.ParseExact(user.Attribute("LastVisit").Value, "dd-MM-yyyy HH:mm:ss",CultureInfo.InvariantCulture);
                    }
                    foreach (var stream in streamchildren)
                    {
                        newuser.addStream(stream.Attribute("Channel").Value, true);
                    }

                    newuser.bIsLoggingOp = Convert.ToBoolean(user.Attribute("isloggingOp").Value);
                    newuser.VisitCounter = Int32.Parse(user.Attribute("VisitCount").Value);
                    LUserList.Add(newuser);
                }
                var OrderedUserList = LUserList.OrderByDescending(x => x.LastVisit).ToList();
                LUserList = OrderedUserList;
                System.Xml.Serialization.XmlSerializer xmlserializer = new System.Xml.Serialization.XmlSerializer(LUserList.GetType());
                var path = Directory.GetCurrentDirectory() + "/XML/Usersv2.xml";
                System.IO.FileStream file = System.IO.File.Create(path);
                xmlserializer.Serialize(file,LUserList);
                file.Close();
            }
        }