public void Dispose() { UserDB.Save(); Filters = null; UserDB = null; ChannelInstance = null; }
internal void GetProperty(SuiBot_ChannelInstance channelInstance, ChatMessage lastMessage) { if (lastMessage.UserRole <= Role.Mod) { var msg = lastMessage.Message.StripSingleWord().ToLower(); if (msg != "") { try { Type _type = this.GetType(); var properties = _type.GetProperties(); var foundProperty = properties.FirstOrDefault(x => x.Name.ToLower() == msg); if (foundProperty != null) { string result = foundProperty.GetValue(this, null).ToString(); channelInstance.SendChatMessageResponse(lastMessage, string.Format("{0} == {1}", foundProperty.Name, result)); } else { channelInstance.SendChatMessageResponse(lastMessage, "No proparty was found"); } } catch { channelInstance.SendChatMessageResponse(lastMessage, "Error looking for property"); } } } }
public _MemeComponents(SuiBot_ChannelInstance channelInstance, Storage.MemeConfig memeConfig) { this.channelInstance = channelInstance; this.memeConfig = memeConfig; this.memeComponents = new Dictionary <string, MemeCompnent>(); ReloadComponents(false); }
public Leaderboards(SuiBot_ChannelInstance channelInstance) { this.channelInstance = channelInstance; GameOverride = false; CurrentGame = ""; LevelOverride = ""; CategoryOverride = ""; PreferedCategory = ""; SubcategoriesOverride = new Dictionary <string, string>(); }
public override void DoWork(SuiBot_ChannelInstance channelInstance, ChatMessage lastMessage) { //Blame Jerma - https://www.youtube.com/watch?v=vdVnnMOTe3Q if (lastMessage.Message.Contains(" ")) { var target = lastMessage.Message.Split(new char[] { ' ' }, 2)[1]; if (target != " ") { channelInstance.SendChatMessageResponse(lastMessage, string.Format("🐀 Rats rats we are the rats - Celebrating yet another birthday bash! {0} it's your birthday today - Cake and Ice cream is on it's way! (and) {0} been such a good boy this year - Open up your gifts while we all cheer! 🐀", target), true); } else { channelInstance.SendChatMessageResponse(lastMessage, "!RatsBirthday requires a target to be specified after \"spacebar\", e.g. !ratsbirthday SuiBot"); } } else { channelInstance.SendChatMessageResponse(lastMessage, "!RatsBirthday requires a target to be specified after \"spacebar\", e.g. !ratsbirthday SuiBot"); } }
public static void GetRaces(SuiBot_ChannelInstance ChannelInstance) { try { if (JsonGrabber.GrabJson(GetUri("races"), out string response)) { string[] twitches = GetEntrantsTwitches(response, ChannelInstance.Channel); if (twitches != null) { ChannelInstance.SendChatMessage("http://kadgar.net/live/" + string.Join("/", twitches)); } else { ChannelInstance.SendChatMessage("Nothing found"); } } } catch { ChannelInstance.SendChatMessage("Some kind of error. Go, poke Sui to fix that"); } }
public override void DoWork(SuiBot_ChannelInstance channelInstance, ChatMessage lastMessage) { var chunks = lastMessage.Message.GetChunks('\"'); if (chunks.Length > 4) { channelInstance.SendChatMessageResponse(lastMessage, "Up to 4 lines allowed!"); } else if (chunks.Length < 1) { channelInstance.SendChatMessageResponse(lastMessage, "Tombstome requires at least 1 (and max. 4) lines. e.g. !tombstone \"Line1\" \"Blah line 2\" etc."); } else { var urlBuilder = string.Format("http://www.tombstonebuilder.com/generate.php?top1={0}&top2={1}&top3={2}&top4={3}", chunks[0], chunks.Length > 1 ? chunks[1].GetUrlSafeString() : "", chunks.Length > 2 ? chunks[2].GetUrlSafeString() : "", chunks.Length > 3 ? chunks[3].GetUrlSafeString() : "" ); channelInstance.SendChatMessageResponse(lastMessage, urlBuilder); } }
public Quotes(SuiBot_ChannelInstance ChannelInstance) { this.ChannelInstance = ChannelInstance; ChannelQuotes = Storage.Quotes.Load(ChannelInstance.Channel); }
internal void SetPropety(SuiBot_ChannelInstance channelInstance, ChatMessage lastMessage) { var msg = lastMessage.Message.StripSingleWord(); if (msg != "") { try { Object target; Type _type; PropertyInfo[] properties; PropertyInfo foundProperty = null; if (msg.StartsWithLazy("memecomponents.")) { msg = msg.Split(new char[] { '.' }, 2)[1]; target = MemeComponents; } else if (msg.StartsWithLazy("genericutil.")) { msg = msg.Split(new char[] { '.' }, 2)[1]; target = GenericUtil; } else { target = this; } _type = target.GetType(); properties = _type.GetProperties(); foundProperty = properties.FirstOrDefault(x => msg.ToLower().StartsWithLazy(x.Name)); if (foundProperty != null) { msg = msg.StripSingleWord(); if (foundProperty.PropertyType == typeof(bool)) { if (bool.TryParse(msg, out bool res)) { var old = foundProperty.GetValue(target, null); foundProperty.SetValue(target, res, null); channelInstance.SendChatMessageResponse(lastMessage, string.Format("Set {0} to {1} (was {2}).", foundProperty.Name, res.ToString(), old.ToString())); Save(); } else { channelInstance.SendChatMessageResponse(lastMessage, "Failed to parse bool value."); } } else if (foundProperty.PropertyType == typeof(byte)) { if (byte.TryParse(msg, out byte res)) { var old = foundProperty.GetValue(target, null); foundProperty.SetValue(target, res, null); channelInstance.SendChatMessageResponse(lastMessage, string.Format("Set {0} to {1} (was {2}).", foundProperty.Name, res.ToString(), old.ToString())); Save(); } else { channelInstance.SendChatMessageResponse(lastMessage, "Failed to parse byte value."); } } else if (foundProperty.PropertyType == typeof(short)) { if (short.TryParse(msg, out short res)) { var old = foundProperty.GetValue(target, null); foundProperty.SetValue(target, res, null); channelInstance.SendChatMessageResponse(lastMessage, string.Format("Set {0} to {1} (was {2}).", foundProperty.Name, res.ToString(), old.ToString())); Save(); } else { channelInstance.SendChatMessageResponse(lastMessage, "Failed to short bool value."); } } else if (foundProperty.PropertyType == typeof(int)) { if (int.TryParse(msg, out int res)) { var old = foundProperty.GetValue(target, null); foundProperty.SetValue(target, res, null); channelInstance.SendChatMessageResponse(lastMessage, string.Format("Set {0} to {1} (was {2}).", foundProperty.Name, res.ToString(), old.ToString())); Save(); } else { channelInstance.SendChatMessageResponse(lastMessage, "Failed to parse int value."); } } else if (foundProperty.PropertyType == typeof(float)) { if (float.TryParse(msg, out float res)) { var old = foundProperty.GetValue(target, null); foundProperty.SetValue(target, res, null); channelInstance.SendChatMessageResponse(lastMessage, string.Format("Set {0} to {1} (was {2}).", foundProperty.Name, res.ToString(), old.ToString())); Save(); } else { channelInstance.SendChatMessageResponse(lastMessage, "Failed to parse float value."); } } else if (foundProperty.PropertyType == typeof(long)) { if (long.TryParse(msg, out long res)) { var old = foundProperty.GetValue(target, null); foundProperty.SetValue(target, res, null); channelInstance.SendChatMessageResponse(lastMessage, string.Format("Set {0} to {1} (was {2}).", foundProperty.Name, res.ToString(), old.ToString())); Save(); } else { channelInstance.SendChatMessageResponse(lastMessage, "Failed to parse long value."); } } else if (foundProperty.PropertyType == typeof(double)) { if (double.TryParse(msg, out double res)) { var old = foundProperty.GetValue(target, null); foundProperty.SetValue(target, res, null); channelInstance.SendChatMessageResponse(lastMessage, string.Format("Set {0} to {1} (was {2}).", foundProperty.Name, res.ToString(), old.ToString())); Save(); } else { channelInstance.SendChatMessageResponse(lastMessage, "Failed to parse double value."); } } else if (foundProperty.PropertyType == typeof(string)) { var old = foundProperty.GetValue(target, null); foundProperty.SetValue(target, msg, null); channelInstance.SendChatMessageResponse(lastMessage, string.Format("Set \"{0}\" to \"{1}\" (was \"{2}\").", foundProperty.Name, msg, old.ToString())); Save(); } } else { channelInstance.SendChatMessageResponse(lastMessage, "No proparty was found"); } } catch (Exception ex) { channelInstance.SendChatMessageResponse(lastMessage, "Error setting property"); ErrorLogging.WriteLine(ex.ToString()); } } }
public virtual void DoWork(SuiBot_ChannelInstance channelInstance, ChatMessage lastMessage) { channelInstance.SendChatMessageResponse(lastMessage, "This method is suppose to be overriden with child method! GET GUD!"); }
public ViewerPB(SuiBot_ChannelInstance ChannelInstance) { this.ChannelInstance = ChannelInstance; this.pbStorage = Storage.ViewerPBStorage.Load(ChannelInstance.Channel); }
public CustomCvars(SuiBot_ChannelInstance ChannelInstance) { this.ChannelInstance = ChannelInstance; Cvars = Storage.CustomCvars.Load(ChannelInstance.Channel); }
public PCGW(SuiBot_ChannelInstance ChannelInstance, TwitchStatusUpdate TwitchUpdateInstance) { this.ChannelInstance = ChannelInstance; this.TwitchUpdateInstance = TwitchUpdateInstance; }
/// <summary> /// Constructor for IntervalMessages component created for channel /// </summary> /// <param name="ChannelInstance">Instance of a SuiBot_ChannelInstance</param> public IntervalMessages(SuiBot_ChannelInstance ChannelInstance) { this.ChannelInstance = ChannelInstance; IntervalMessagesStorage = Storage.IntervalMessages.Load(ChannelInstance.Channel); }
public GenericUtil(SuiBot_ChannelInstance ChannelInstance, TwitchStatusUpdate TwitchUpdateInstance) { this.ChannelInstance = ChannelInstance; this.TwitchUpdateInstance = TwitchUpdateInstance; }
public ChatFiltering(SuiBot_ChannelInstance ChannelInstance) { this.ChannelInstance = ChannelInstance; Filters = Storage.ChatFilters.Load(ChannelInstance.Channel); UserDB = Storage.ChatFilterUsersDB.Load(ChannelInstance.Channel); }