private void AddMyUser(object sender, MessageEventArgs e, List<string> parameters) { if(LUserList.Where(x => x.Name.ToLower() == e.User.Name.ToLower()).Count()>0) { e.User.SendMessage("User already exists"); } else { DataFiles.User newuser = new DataFiles.User(); newuser.Name = e.User.Name.ToLower(); LUserList.Add(newuser); SaveUserList(); e.User.SendMessage("User added"); } }
private void User_Joined(object sender, UserEventArgs e) { if (Properties.Settings.Default.SilentMode.ToString() != "true") { if (xmlprovider == null) { xmlprovider = new XMLProvider(); } #region whisperstatsonjoin NormalisedUser normaliseduser = new NormalisedUser(); normaliseduser.orig_username = e.User.Name; IEnumerable<DataFiles.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)"; bot.Servers.First().AllChannels.Where(x => x.Name == "botspam").First().SendMessage(output); } else { String output = "This is " + normaliseduser.normalised_username() + "'s first visit."; bot.Servers.First().AllChannels.Where(x => x.Name == "botspam").First().SendMessage(output); DataFiles.User newUser = new DataFiles.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(",", ""); DataFiles.User user = getUser(normaliseduser.normalised_username().ToLower()); if (user != null) if (user.isSubscribed(_streamname)) { e.User.SendMessage(String.Format( "Stream running: _{0}_ ({1}) at {2}", _streamname, xmlprovider.StreamInfo(_streamname, "game"), xmlprovider.StreamInfo(_streamname, "URL") )); } } normaliseduser = null; } }