public static List<Channels> ConvertDataTable(DataTable dTable) { List<Channels> ReturnedChannels = new List<Channels>(); foreach(DataRow row in dTable.Rows) { Channels twitchChannel = new Channels(); twitchChannel.ChannelName = row["ChannelName"].ToString(); twitchChannel.ChannelID = Convert.ToInt32(row["ChannelID"]); ReturnedChannels.Add(twitchChannel); } return ReturnedChannels; }
/// <summary> /// Command to mimic a function that the original mumbo bot had. Typos are intentional, do not fix :) /// </summary> /// <param name="CurChan"></param> public void DoTransform(Channels CurChan, string user) { LastTransform = DateTime.Now; try { if (!String.IsNullOrWhiteSpace(user)) { Random randGen = new Random(); int intValue = randGen.Next(50, 840); intValue = Convert.ToInt32(Math.Round(Convert.ToDecimal(intValue) / Convert.ToDecimal(100))); string message = ""; switch (intValue) { case 1: message = String.Format("\x01" + "ACTION transform {0} into funny looking termite!\x01", user); break; case 2: message = String.Format("\x01" + "ACTION magically change {0} into tiny little bouncing pumpkin!\x01", user); break; case 3: message = String.Format("\x01" + "ACTION transform {0} into T-Rex. Wait, who am I? Wumba? I change you back.\x01", user); break; case 4: message = String.Format("\x01" + "ACTION transforms {0} into a funny looking termite!\x01", user); break; case 5: message = String.Format("\x01" + "ACTION magically change {0} into ...washing machine? That not right. I hope you not go for World Record!\x01", user); break; case 6: message = String.Format("\x01" + "ACTION magically change {0} into little crocodile! Yes! Mumbo need new shoes! Only kidding...\x01", user); break; case 7: message = String.Format("\x01" + "ACTION magically change {0} into silly little Bumble Bee!\x01", user); break; case 8: message = String.Format("\x01" + "ACTION turn {0} into big fat Walrus!!\x01", user); break; default: message = String.Format("\x01" + "ACTION magically change {0} into silly little Bumble Bee!\x01", user); break; }//switch (intValue) ircConnection.LocalUser.SendMessage(CurChan.ChannelName, message); }//if (!String.IsNullOrWhiteSpace(user)) }//try catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; }//catch (Exception ex) }
public bool AddUser(string username, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; IrcChannel findChannel = null; foreach (IrcChannel ircChannel in ircConnection.Channels) { if(ircChannel.Name == target.Name) { findChannel = ircChannel; } } if (Utilities.CheckOp(source.Name, findChannel)) { try { Channels Watch = new Channels(); foreach (Channels c in TwitchChannels) { if (findChannel.Name == c.ChannelName) { Watch = c; }//if (findChannel.Name == c.ChannelName) }//foreach (Channels c in TwitchChannels) // config writing XElement newStreamer = new XElement("streamer"); newStreamer.SetAttributeValue("value", username); XElement xElem = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == Watch.ChannelName); xElem.Descendants("streamers").FirstOrDefault().Add(newStreamer); TwitchStuff twitchInfo = new TwitchStuff(); twitchInfo.UpdateInfo(username,this); Watch.Streamers.Add(username); Watch.StreamInfo.Add(twitchInfo); returnvalue = true; ConfigDocument.Save(FileName); }//try catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; returnvalue = false; } } ModifyingConfig = false; return returnvalue; }
// this is a hot mess, trying to improve it public void ParseConfig() { ConfigDocument = XDocument.Load(FileName); XElement serversNode = ConfigDocument.Root; foreach (XElement serverNode in serversNode.Descendants("server")) { ServerNodes.Add(serverNode); try { string updateToDB = serverNode.Attribute("updatedb").Value; if (updateToDB == "true") { this.ConnectionString = serverNode.Attribute("ConnString").Value; this.UseDB = true; } } catch (Exception ex) { } XElement userinfo = serverNode.Descendants("userinfo").FirstOrDefault(); BotUsername = userinfo.Descendants("nick").FirstOrDefault().Value; BotRealname = userinfo.Descendants("name").FirstOrDefault().Value; try { OwnerIdentity = userinfo.Descendants("ownerident").FirstOrDefault().Value; } catch { OwnerIdentity = ""; } try { HasOwner = Convert.ToBoolean(userinfo.Descendants("hasowner").FirstOrDefault().Value); } catch { HasOwner = false; } try { UsePassword = Convert.ToBoolean(userinfo.Descendants("needsserverpassword").FirstOrDefault().Value.ToString()); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; UsePassword = false; }//catch (Exception ex) BotInfo.NickName = BotUsername; BotInfo.UserName = BotUsername; BotInfo.RealName = BotRealname; //BotInfo.Password = userinfo.Descendants("userpassword").FirstOrDefault().Value; BotInfo.Password = ServerNodes.Descendants("serverpassword").FirstOrDefault().Value; ServerName = serverNode.Attribute("id").Value; Console.WriteLine("Server pointed to: " + ServerName); List<TwitchStuff> StreamersList = new List<TwitchStuff>(); TwitchStuff StreamInfo = new TwitchStuff(); LiveMessage = serversNode.Elements("liveannouncement").FirstOrDefault().Attribute("value").Value.ToString(); string valuecheck = serversNode.Elements("liveannouncement").FirstOrDefault().Value; XElement serversubnode = serversNode.Elements("streamannouncement").FirstOrDefault(); BaseMessageStartStreaming = serversubnode.Attribute("value").Value.ToString(); ChangeMessage = serversNode.Elements("titlechangeannouncement").FirstOrDefault().Attribute("value").Value.ToString(); List<XElement> channelNodeElements = new List<XElement>(); foreach (XElement channelNode in serverNode.Descendants("channel")) { List<XElement> StreamerNodes = new List<XElement>(); channelNodeElements.Add(channelNode); #region TODO look into better error handling for this shit lol -- Pull channel config values valuecheck = ""; Channels channelMonitor = new Channels(); try { valuecheck = channelNode.Descendants("liveannouncement").FirstOrDefault().Attribute("value").Value.ToString(); }//try catch { valuecheck = ""; }//catch if (valuecheck != "") // custom announcements inside the channel, let's use them instead. { channelMonitor.LiveMessage = valuecheck; }//if (valuecheck != "") valuecheck = ""; try { valuecheck = channelNode.Attribute("useinfo").Value.ToString(); } catch { valuecheck = ""; } if (valuecheck != "") { channelMonitor.InfoCommands = Convert.ToBoolean(valuecheck); } try { valuecheck = channelNode.Attribute("").Value.ToString(); } catch { valuecheck = ""; } if (valuecheck != "") { channelMonitor.Mystery = Convert.ToBoolean(valuecheck); } try { valuecheck = channelNode.Descendants("streamannouncement").FirstOrDefault().Attribute("value").Value.ToString(); }//try catch { valuecheck = ""; }//catch if (valuecheck != "") // custom announcements inside the channel, let's use them instead. { channelMonitor.AnnounceMessage = valuecheck; }//if (valuecheck != "") valuecheck = ""; try { valuecheck = channelNode.Descendants("titlechangeannouncement").FirstOrDefault().Attribute("value").Value.ToString(); } catch { valuecheck = ""; } if (valuecheck != "") // custom announcements inside the channel, let's use them instead. { channelMonitor.ChangedMessage = valuecheck; }//if (valuecheck != "") channelMonitor.ChannelName = channelNode.Attribute("id").Value; try { valuecheck = channelNode.Attribute("usewhitelist").Value.ToString(); channelMonitor.UseWhiteList = Convert.ToBoolean(channelNode.Attribute("usewhitelist").Value.ToString()); }//try catch { channelMonitor.UseWhiteList = false; }//catch try { channelMonitor.UseBlackList = Convert.ToBoolean(channelNode.Attribute("useblacklist").Value.ToString()); }//try catch { channelMonitor.UseBlackList = false; }//catch try { channelMonitor.ChannelPassword = channelNode.Attribute("password").Value.ToString(); }//try catch { channelMonitor.ChannelPassword = ""; }//catch #endregion channelMonitor.Streamers = new List<string>(); Console.WriteLine("Adding Channel " + channelMonitor.ChannelName + " to the monitor list"); List<string> Streamers = new List<string>(); TwitchAPIInterface checkTwitch = new TwitchAPIInterface(); StreamersList = new List<TwitchStuff>(); XElement whiteListInfo = channelNode.Elements("whitelist").FirstOrDefault(); if (whiteListInfo != null) { foreach (XElement whitelistitem in whiteListInfo.Elements("game").DefaultIfEmpty()) { string gamename = whitelistitem.Attribute("name").Value.ToString(); channelMonitor.WhiteList.Add(gamename); }//foreach (XElement whitelistitem in whiteListInfo.Elements("game").DefaultIfEmpty()) }//if (whiteListInfo != null) XElement blackListInfo = channelNode.Elements("blacklist").FirstOrDefault(); if (blackListInfo != null) { foreach (XElement BlackListitem in blackListInfo.Elements("game").DefaultIfEmpty()) { string gamename = BlackListitem.Attribute("name").Value.ToString(); channelMonitor.BlackList.Add(gamename); }//foreach (XElement BlackListitem in blackListInfo.Elements("game").DefaultIfEmpty()) }//if (blackListInfo != null) foreach (XElement streamers in channelNode.Elements("streamers")) { StreamersNodes.Add(channelMonitor.ChannelName, streamers); } foreach (XElement streamer in channelNode.Elements("streamers").Elements("streamer").ToList()) { StreamerNodes.Add(streamer); try { string twitchid = streamer.Attribute("value").Value.ToString(); Streamers.Add(twitchid); bool setnoticevalue = false; try { setnoticevalue = Convert.ToBoolean(streamer.Attribute("setnotice").Value.FirstOrDefault()); } catch { setnoticevalue = false; } StreamInfo = new TwitchStuff(); StreamInfo.setnotice = setnoticevalue; if (StreamInfo.UpdateInfo(twitchid,this) != false) { if (StreamInfo.streamerlive == "true") { } } else { StreamInfo = new TwitchStuff(twitchid); Console.WriteLine("Adding offline stream info for: " + StreamInfo.streamername); }//else channelMonitor.StreamInfo.Add(StreamInfo); channelMonitor.Streamers.Add(StreamInfo.streamername); if(!AllStreamers.Keys.Contains(StreamInfo.streamername)) AllStreamers.Add(StreamInfo.streamername, StreamInfo); }//try catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; continue; }//catch (Exception ex) }//foreach (XElement streamer in channelNode.Elements("streamers").Elements("streamer").ToList()) channelMonitor.LastLiveAnnouncement = DateTime.Now.AddMinutes(-3); TwitchChannels.Add(channelMonitor); List<string> raceList = new List<string>(); foreach (XElement race in channelNode.Elements("races").Elements("race").ToList()) { channelMonitor.ChannelRaces.Add(race.Attribute("name").Value.ToString()); Console.WriteLine("Adding watch for race: " + race.Attribute("name").Value.ToString() + " for channel " + channelMonitor.ChannelName); }//foreach (XElement race in channelNode.Elements("races").Elements("race").ToList()) }//foreach (XElement channelNode in serverNode.Descendants("channel")) } }
public bool ChangeAnnounceMessage(string MsgTitle, string newMsg, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; XElement xElem = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == ChannelWatch.ChannelName); XElement announce = new XElement(MsgTitle); if (xElem.Descendants(MsgTitle).Count() > 0) { announce = xElem.Descendants(MsgTitle).FirstOrDefault(); } announce.SetValue(newMsg); if (xElem.Descendants(MsgTitle).Count() == 0) { xElem.Add(announce); } ChannelWatch.AnnounceMessage = newMsg; //ChannelWatch.WhiteList.Add(game); returnvalue = true; ConfigDocument.Save(FileName); ModifyingConfig = false; return returnvalue; }
public bool AddWhiteList(string game, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; XElement xElem = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == ChannelWatch.ChannelName); XElement whiteList = new XElement("whitelist"); if(xElem.Descendants("whitelist").Count() > 0) { whiteList = xElem.Descendants("whitelist").FirstOrDefault(); } else { xElem.Add(whiteList); } XElement newGame = new XElement("game"); XAttribute newGameAttr = new XAttribute("name", game); newGame.Add(newGameAttr); whiteList.Add(newGame); ChannelWatch.WhiteList.Add(game); returnvalue = true; ConfigDocument.Save(FileName); ModifyingConfig = false; return returnvalue; }
void SakegeistCommands(Channels curChan, IrcMessageEventArgs e) { string message = e.Text.ToLower(); if (message.StartsWith("!bet")) { if (chickenBettingAllowed) { bool foundTarget = false; for (int i = 0; i < cBetters.Count; ++i) { if (cBetters[i].Name == e.Source.Name) { foundTarget = true; Console.WriteLine(e.Source.Name + " is already betting"); } } if (!foundTarget) ChickenBet(message, e.Source.Name); } } if (e.Source.Name.ToLower() == "moonizz" || e.Source.Name.ToLower() == "sakegeist") { if (message.StartsWith("!bet won")) { if (message.Length == 10) { ChickenBetWon(curChan, string.Format("{0}", message[9])); } } if (message.StartsWith("!bet open")) { chickenBettingAllowed = true; client.LocalUser.SendMessage(curChan.ChannelName, "Chicken betting is now OPEN!"); } if (message.StartsWith("!bet closed")) { if (chickenBettingAllowed) { chickenBettingAllowed = false; client.LocalUser.SendMessage(curChan.ChannelName, "Chicken betting is now CLOSED!"); } } if (message.StartsWith("!chickenboard")) { CheckChickenBoard(curChan.ChannelName); } } }
public void SetCompetitors(Channels channel, string message, string nick, IrcChannel ircChannel) { if (channel.InfoCommands) { if(Utilities.CheckOp(nick, ircChannel)) { message = message.Replace("!setmatch ", ""); string[] vs = message.Split(' '); channel.Competitor1 = vs[0]; channel.Competitor2 = vs[1]; ircConnection.LocalUser.SendMessage(channel.ChannelName, "Competitors set."); } } }
public bool SetWhiteList(bool value, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; XElement xElem = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == ChannelWatch.ChannelName); if (xElem.Attributes("usewhitelist") == null) { XAttribute whiteList = new XAttribute("usewhitelist", value.ToString()); xElem.Add(whiteList); } else { if (value) { xElem.Attribute("usewhitelist").SetValue("true"); ChannelWatch.UseWhiteList = true; } else { xElem.Attribute("usewhitelist").SetValue("false"); ChannelWatch.UseWhiteList = false; } } returnvalue = true; ConfigDocument.Save(FileName); ModifyingConfig = false; return returnvalue; }
public List<string> GetLiveList(Channels channel, bool UseLiveAll) { bool foundstream = false; bool foundunapprovedstream = false; List<string> listmessages = new List<string>(); //channel.LastLiveAnnouncement = DateTime.Now; string liveList = ""; foreach (TwitchStuff streamInfo in channel.StreamInfo) { bool meetswhitelist = true; if (streamInfo.streamerlive == "true") { string addToList = config.LiveMessage; if (channel.LiveMessage != "") addToList = channel.LiveMessage; addToList = Utilities.TemplateString(addToList, streamInfo.streamername, streamInfo.game, streamInfo.streamerviewcount, streamInfo.streamname, config.ServerName.ToLower().Contains("twitch.tv")); liveList = addToList.Trim(); meetswhitelist = channel.MeetsWhiteBlackList(streamInfo); if (UseLiveAll) { meetswhitelist = true; } if (meetswhitelist) { foundstream = true; listmessages.Add(liveList); } else { foundunapprovedstream = true; } liveList = ""; } } if (!foundstream) { if (foundunapprovedstream) { listmessages.Add("No one is currently streaming a whitelisted game. Use liveall to see streams."); } else { listmessages.Add("No one is currently streaming."); } } return listmessages; }
public void SendLiveList(Channels channel, string nick, string[] args) { bool foundstream = false; bool foundunapprovedstream = false; int livestreams = 0; bool hasArgs = (args.Length > 0); List<TwitchStuff> filteredStreamInfos = channel.StreamInfo; foreach (TwitchStuff streamInfo in channel.StreamInfo) { if (streamInfo.streamerlive == "true") { if (channel.MeetsWhiteBlackList(streamInfo)) { if (hasArgs) { if(args.Any(s => streamInfo.game.ToLower().Contains(s.ToLower()) || streamInfo.streamname.ToLower().Contains(s.ToLower()))) livestreams++; } else livestreams++; } } } bool announcetochannel = true; if (livestreams >= 4) { announcetochannel = false; } int timecheck = 60; if (!announcetochannel) { timecheck = 5; } if (channel.LastLiveAnnouncement.AddSeconds(timecheck) <= DateTime.Now) { if (announcetochannel) { channel.LastLiveAnnouncement = DateTime.Now; } string liveList = ""; foreach (TwitchStuff streamInfo in channel.StreamInfo) { bool meetswhitelist = false; if (streamInfo.streamerlive == "true") { string addToList = config.LiveMessage; if (channel.LiveMessage != "") addToList = channel.LiveMessage;//if (channel.LiveMessage != "") addToList = Utilities.TemplateString(addToList, streamInfo.streamername, streamInfo.game, streamInfo.streamerviewcount, streamInfo.streamname, config.ServerName.ToLower().Contains("twitch.tv")); liveList = addToList.Trim(); meetswhitelist = channel.MeetsWhiteBlackList(streamInfo); if (args.Length > 0) { // !LIVE SEARCH FUNCTIONALITY if (!args.Any(s => streamInfo.game.ToLower().Contains(s.ToLower()) || streamInfo.streamname.ToLower().Contains(s.ToLower()))) meetswhitelist = false; } if (meetswhitelist) { if (announcetochannel) { if (!streamInfo.setnotice) { foundstream = true; ircConnection.LocalUser.SendMessage(channel.ChannelName, liveList); }//if (!streamInfo.setnotice) else { foundunapprovedstream = true; }//else }//if(announcetochannel) else { foundstream = true; ircConnection.LocalUser.SendNotice(nick, liveList); }//else }//if (meetswhitelist) else { foundunapprovedstream = true; }//else liveList = ""; }//if (streamInfo.streamerlive == "true") }//foreach (TwitchStuff streamInfo in channel.StreamInfo) if (!foundstream) { if (foundunapprovedstream) { ircConnection.LocalUser.SendMessage(channel.ChannelName, "No one is currently cleared to report on !live. Use !liveall to see streams."); } else { ircConnection.LocalUser.SendMessage(channel.ChannelName, "No one is currently streaming."); } } } }
public void SendCompetitors(Channels channel) { if (channel.InfoCommands) { ircConnection.LocalUser.SendMessage(channel.ChannelName, String.Format("The current contestants are: http://www.twitch.tv/{0} vs http://www.twitch.tv/{1}", channel.Competitor1, channel.Competitor2)); } }
public void SendAllLiveList(Channels channel, IIrcMessageSource e) { bool foundstream = false; channel.LastLiveAllMessage = DateTime.Now; string liveList = ""; foreach (TwitchStuff streamInfo in channel.StreamInfo) { if (streamInfo.streamerlive == "true") { string addToList = config.LiveMessage; if (channel.LiveMessage != "") { addToList = channel.LiveMessage; } addToList = Utilities.TemplateString(addToList, streamInfo.streamername, streamInfo.game, streamInfo.streamerviewcount, streamInfo.streamname, config.ServerName.ToLower().Contains("twitch.tv")); liveList = addToList.Trim(); foundstream = true; ircConnection.LocalUser.SendNotice(e.Name, liveList); liveList = ""; } } if (!foundstream) { ircConnection.LocalUser.SendMessage(channel.ChannelName, "No one is currently streaming."); } }
// This is what happens when a privmsg gets received (e.g. someone /msg's the bot) public void LocalUser_MessageReceived(object sender, IrcMessageEventArgs e) { Channels Channel = new Channels(); bool foundchannel = false; string[] cmdargs = e.Text.Split(' '); if (cmdargs.Length <= 1 && (cmdargs[0] != "help" && cmdargs[0] != "listchannels")) { ircConnection.LocalUser.SendMessage(e.Source.Name, String.Format("Try /msg {0} help", config.BotInfo.NickName)); } else if (cmdargs[0] == "help") { SendHelp(cmdargs, e.Source); }//else if (cmdargs[0] == "help" ) else if (cmdargs[0] == "listchannels") { foreach (Channels c in config.TwitchChannels) { if (c.Streamers.Count > 0) ircConnection.LocalUser.SendMessage(e.Source.Name, c.ChannelName); }//foreach (Channels c in config.TwitchChannels) }//else if (cmdargs[0] == "listchannels") else { foreach (Channels c in config.TwitchChannels) { if (c.ChannelName == cmdargs[1]) { foundchannel = true; Channel = c; }//if (c.ChannelName == cmdargs[1]) }//foreach (Channels c in config.TwitchChannels) if (foundchannel) { // we want to do some things here. switch (cmdargs[0]) { case "live": List<string> LiveReport = GetLiveList(Channel, false); foreach (string s in LiveReport) { ircConnection.LocalUser.SendMessage(e.Source.Name, s); } break; case "liveall": List<string> LiveAllReport = GetLiveList(Channel, true); foreach (string s in LiveAllReport) { ircConnection.LocalUser.SendMessage(e.Source.Name, s); } break; case "watching": string WatchingReport = string.Empty; foreach (string s in Channel.Streamers) { WatchingReport += s + " "; if (WatchingReport.Length > 250) { ircConnection.LocalUser.SendMessage(e.Source.Name, WatchingReport); WatchingReport = string.Empty; } } if (WatchingReport.Length > 0) { ircConnection.LocalUser.SendMessage(e.Source.Name, WatchingReport); WatchingReport = string.Empty; } break; default: break; } }//if (foundchannel) else { ircConnection.LocalUser.SendMessage(e.Source.Name, "No channel by that name is in my watch list."); }//else }//else //Console.WriteLine(String.Format("<{0}:{1}> {2}", e.Source.Name, e.Targets[0].Name, e.Text)); }
public bool RemoveUser(string username, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; IrcChannel findChannel = null; foreach (IrcChannel ircChannel in ircConnection.Channels) { if (ircChannel.Name == target.Name) { findChannel = ircChannel; } } if (Utilities.CheckOp(source.Name, findChannel)) { try { Channels Watch = new Channels(); foreach (Channels c in TwitchChannels) { if (findChannel.Name == c.ChannelName) { Watch = c; }//if (findChannel.Name == c.ChannelName) }//foreach (Channels c in TwitchChannels) Watch.Streamers.Remove(username); TwitchStuff twitchInfo = new TwitchStuff(); foreach (TwitchStuff huntInfo in Watch.StreamInfo) { if (huntInfo.streamername == username) { twitchInfo = huntInfo; }//if (huntInfo.streamername == username) }//foreach (TwitchStuff huntInfo in Watch.StreamInfo) Watch.StreamInfo.Remove(twitchInfo); // config writing if(AllStreamers.Keys.Contains(username)) { AllStreamers.Remove(username); } XElement chanNode = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == Watch.ChannelName); XElement streamercheck = chanNode.Element("streamers").Descendants("streamer").First(x => x.Attribute("value").Value == username); if (streamercheck != null) streamercheck.Remove(); returnvalue = true; ConfigDocument.Save(FileName); }//try catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; returnvalue = false; }//catch } ModifyingConfig = false; return returnvalue; }
public bool SetNotice(string username, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection, bool SetNoticeValue) { ModifyingConfig = true; bool returnvalue = false; IrcChannel findChannel = null; foreach (IrcChannel ircChannel in ircConnection.Channels) { if (ircChannel.Name == target.Name) { findChannel = ircChannel; } } if (ChannelWatch.Streamers.Contains(username)) { try { TwitchStuff twitchInfo = new TwitchStuff(); foreach (TwitchStuff huntInfo in ChannelWatch.StreamInfo) { if (huntInfo.streamername == username) { twitchInfo = huntInfo; }//if (huntInfo.streamername == username) }//foreach (TwitchStuff huntInfo in Watch.StreamInfo) XElement chanNode = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == ChannelWatch.ChannelName); XElement streamercheck = chanNode.Element("streamers").Descendants("streamer").First(x => x.Attribute("value").Value == username); if (streamercheck != null) { if (SetNoticeValue) { try { streamercheck.Attribute("setnotice").SetValue("true"); } catch { streamercheck.Add(new XAttribute("setnotice", "true")); } twitchInfo.setnotice = true; } else { streamercheck.Attribute("setnotice").SetValue("false"); twitchInfo.setnotice = false; } } returnvalue = true; ConfigDocument.Save(FileName); }//try catch (Exception ex) { returnvalue = false; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; }//catch } else { ircConnection.LocalUser.SendNotice(source.Name, "You are not on the streamer list."); } ModifyingConfig = false; return returnvalue; }
void ChickenBetWon(Channels curChan, string n) { string cwin = "Winners are: "; int success; bool first = true; if (int.TryParse(n, out success)) { for (int i = 0; i < cBetters.Count; ++i) { if (cBetters[i].Number == success) { AddChickenScore(cBetters[i].Name); if (first) cwin = string.Format("{0} {1}", cwin, cBetters[i].Name); else cwin = string.Format("{0},{1}", cwin, cBetters[i].Name); } } cBetters.Clear(); } client.LocalUser.SendMessage(curChan.ChannelName, cwin); }
public void CheckMessages(IrcClient c, Channels curChan, IrcMessageEventArgs e) { if (!xmlLoaded) { LoadXML(); xmlLoaded = true; } if (client == null) client = c; bool commandFound = false; if (e.Text[0] == '!') { foreach (BasicTextCommands t in textCommands) { string chan; if (t.channel[0] == '#') chan = t.channel; else chan = string.Format("#{0}", t.channel); if (chan == curChan.ChannelName || t.channel == "#anychannel") { if (e.Text.ToLower() == t.triggerName.ToLower()) { client.LocalUser.SendMessage(curChan.ChannelName, t.responseText); commandFound = true; break; } } } if (!commandFound) { if (curChan.ChannelName == "#sakegeist") { SakegeistCommands(curChan, e); } } if (e.Source.Name.ToLower() == "moonizz" || e.Source.Name.ToLower() == curChan.ChannelName.Substring(1).ToLower()) { if (e.Text.ToLower().StartsWith("!add ")) { string[] splitText = e.Text.Split('\"'); if (splitText.Length == 5) { BasicTextCommands t = new BasicTextCommands(); t.channel = curChan.ChannelName; if (splitText[1][0] == '!') t.triggerName = splitText[1]; else t.triggerName = string.Format("!{0}",splitText[1]); t.responseText = splitText[3]; string chan; bool commandExist = false; for (int i = 0; i < textCommands.Count; ++i) { if (textCommands[i].channel[0] == '#') chan = textCommands[i].channel; else chan = string.Format("#{0}", textCommands[i].channel); if (string.Format("#{0}", textCommands[i].channel) == chan || textCommands[i].channel == chan) { if (textCommands[i].triggerName == t.triggerName) { client.LocalUser.SendMessage(curChan.ChannelName, "Command already exists! Overriding!"); textCommands[i] = t; SaveXML(); commandExist = true; } } } if (!commandExist) { textCommands.Add(t); client.LocalUser.SendMessage(curChan.ChannelName, "Command added"); SaveXML(); } } else{ client.LocalUser.SendMessage(curChan.ChannelName, "Invalid Command, use !add \"!<TriggerText>\" \"<message>\""); } } } } Console.WriteLine(curChan.ChannelName); }
public void SendTournamentInfo(Channels channel) { if (channel.InfoCommands) { ircConnection.LocalUser.SendMessage(channel.ChannelName, "Please go to http://mystery.beatthega.me/ for more information about the tournament."); } }