public void OnTwitchNotification(Channel channel, string notification) { //This is a twitch chat notification for a specific channel! //What kind of notification is it? Let's parse! if (notification.ToLower().Contains("just subscribed")) { //It's a subscription! string subscriber = notification.Split(new string[] { " just" }, StringSplitOptions.None).First(); //is this person a subscriber? User target; if (!channel.UserExists(subscriber)) { //make a new user! target = new User(subscriber, channel); } else { target = channel.GetUser(subscriber); } //Pass it off to the relevant handler in our script Scripting.Script.onNewSubscriber(channel, target); return; } else { Logger.Log.Write("UNHANDLED TWITCH NOTIFICATION: " + channel.name + ":" + notification, ConsoleColor.Yellow); } }
private void OnAction(UserInfo user, string channel, string description) { //Got an action message. Log it and pass it off to the script Channel tempchan = GetChannelByName(channel); User sender; //Do we have this user object already? if (!tempchan.UserExists(user.Nick)) { //Nope, let's make a user object for this channel sender = new User(user.Nick, tempchan); } else { sender = tempchan.GetUser(user.Nick); } //Increase their message count sender.MessagesSent++; //Increase the channels message count tempchan.messagesReceived++; //Log it! Logger.Log.Write(sender.Channel.name + ":" + sender.Nickname + " " + description, ConsoleColor.DarkYellow); //Send this off to our script Scripting.Script.onUserAction(tempchan, sender, description); }
public void OnChannelModeChange(UserInfo who, string channel, ChannelModeInfo[] modes) { Channel tempchan = GetChannelByName(channel); //What kind of modes are we applying foreach (ChannelModeInfo c in modes) { User.PermissionLevel permission; //What kind of permission? if (c.Mode == ChannelMode.ChannelOperator) { permission = User.PermissionLevel.Mod; } else { //WHOA! Logger.Log.Write("UNHANDLED PERMISSION MODE CHANGE: " + c.ToString(), ConsoleColor.Yellow); return; } //Who is the target? User target; if (!tempchan.UserExists(c.Parameter)) { target = new User(c.Parameter, tempchan); } else { target = tempchan.GetUser(c.Parameter); } //Are we adding or removing? if (c.Action == ModeAction.Add) { Logger.Log.Write(channel + " +o " + target.Nickname, ConsoleColor.DarkCyan); target.AddPermission(permission); } else { Logger.Log.Write(channel + " -o " + target.Nickname, ConsoleColor.DarkRed); target.RemovePermission(permission); } } }
public void OnJTVCommand(Channel chan, string command) { User target; //What kind of command was this? string[] split = command.Split(' '); string cmd = split[0].ToLower(); if (cmd == "specialuser") { //Does this user even exist? if (!chan.UserExists(split[1])) { //Nope, let's make a user object target = new User(split[1], chan); } else { target = chan.GetUser(split[1]); } //What kind of specialuser are they? string perm = split[2].ToLower(); if (perm == "subscriber") { target.AddPermission(User.PermissionLevel.Subscriber); } else if (perm == "turbo") { target.AddPermission(User.PermissionLevel.Turbo); } else if (perm == "admin") { target.AddPermission(User.PermissionLevel.Admin); } else if (perm == "staff") { target.AddPermission(User.PermissionLevel.Staff); } else { Logger.Log.Write("UNHANDLED SPECIALUSER: "******"usercolor") { //Set the chat color of a specific user //Does this user even exist? if (!chan.UserExists(split[1])) { //Nope, let's make a user object target = new User(split[1], chan); } else { target = chan.GetUser(split[1]); } target.SetUserColor(split[2]); } else if (cmd == "clearchat") { //Was a target specified? if (split.Count() == 2) { //We need to clear a certain users chat! //TODO: DO SOMETHING HERE Logger.Log.Write("USER CHAT CLEARED: " + split[1]); } else { //Entire chat cleared! //TODO: DO SOMETHING HERE Logger.Log.Write("Chat history cleared"); } } else if (cmd == "emoteset") { //Set the emotes for a specific user //TODO: figure out what this crap is for. We'll just ignore it for now, seems like a waste. } //Slowmode and sub mode are weird, they send entire sentences instead of commands. //We'll keep them unhandled for now... it'd be really ugly to program this. //TODO: Slow mode on/off //TODO: Sub mode on/off else { Logger.Log.Write("Unhandled JTV command: " + command, ConsoleColor.Yellow); } }
public void OnPublic(UserInfo user, string channel, string message) { //Got a public message! Channel tempchan = GetChannelByName(channel); User sender; //Quickly! Is it a twitch notification? We handle those elsewhere! if (user.Nick.ToLower().Equals("twitchnotify")) { //Trigger the proper event and get outta here OnTwitchNotification(tempchan, message); return; } //or maybe it's the new TWITCHCLIENT 3 jtv commands if (user.Nick.ToLower().Equals("jtv")) { //yep, handle it elsewhere! OnJTVCommand(tempchan, message); return; } if (user.Nick.ToLower().Equals("nebezb") && message.Equals("!recompile")) { Logger.Log.Write("Recompiling bot script...", ConsoleColor.DarkGray); try { var tmp = CSScript.Evaluator.LoadFile <Interfaces.IScript>("./script.cs"); Scripting.Script = tmp; // ERROR RIGHT HERE. Logger.Log.Write("Successfully recompiled bot script!", ConsoleColor.DarkGreen); } catch (Exception ex) { Logger.Log.Write("Error recompiling script! " + ex.ToString(), ConsoleColor.Red); } return; } //Do we have this user object already? if (!tempchan.UserExists(user.Nick)) { //Nope, let's make a user object for this channel sender = new User(user.Nick, tempchan); } else { sender = tempchan.GetUser(user.Nick); } //Increase their message count sender.MessagesSent++; //Increase the channels message count tempchan.messagesReceived++; //Log it! Logger.Log.Write(sender.Channel.name + ":" + sender.Nickname + "> " + message); //Send this off to our script Scripting.Script.onChatMessage(tempchan, sender, message); }
public void OnJTVCommand(Channel chan, string command) { User target; //What kind of command was this? string[] split = command.Split(' '); string cmd = split[0].ToLower(); if (cmd == "specialuser") { //Does this user even exist? if (!chan.UserExists(split[1])) //Nope, let's make a user object target = new User(split[1], chan); else target = chan.GetUser(split[1]); //What kind of specialuser are they? string perm = split[2].ToLower(); if (perm == "subscriber") target.AddPermission(User.PermissionLevel.Subscriber); else if (perm == "turbo") target.AddPermission(User.PermissionLevel.Turbo); else if (perm == "admin") target.AddPermission(User.PermissionLevel.Admin); else if (perm == "staff") target.AddPermission(User.PermissionLevel.Staff); else Logger.Log.Write("UNHANDLED SPECIALUSER: "******"usercolor") { //Set the chat color of a specific user //Does this user even exist? if (!chan.UserExists(split[1])) //Nope, let's make a user object target = new User(split[1], chan); else target = chan.GetUser(split[1]); target.SetUserColor(split[2]); } else if (cmd == "clearchat") { //Was a target specified? if (split.Count() == 2) { //We need to clear a certain users chat! //TODO: DO SOMETHING HERE Logger.Log.Write("USER CHAT CLEARED: " + split[1]); } else { //Entire chat cleared! //TODO: DO SOMETHING HERE Logger.Log.Write("Chat history cleared"); } } else if (cmd == "emoteset") { //Set the emotes for a specific user //TODO: figure out what this crap is for. We'll just ignore it for now, seems like a waste. } //Slowmode and sub mode are weird, they send entire sentences instead of commands. //We'll keep them unhandled for now... it'd be really ugly to program this. //TODO: Slow mode on/off //TODO: Sub mode on/off else { Logger.Log.Write("Unhandled JTV command: " + command, ConsoleColor.Yellow); } }
public void OnTwitchNotification(Channel channel, string notification) { //This is a twitch chat notification for a specific channel! //What kind of notification is it? Let's parse! if (notification.ToLower().Contains("just subscribed")) { //It's a subscription! string subscriber = notification.Split(new string[] {" just"}, StringSplitOptions.None).First(); //is this person a subscriber? User target; if (!channel.UserExists(subscriber)) //make a new user! target = new User(subscriber, channel); else target = channel.GetUser(subscriber); //Pass it off to the relevant handler in our script Scripting.Script.onNewSubscriber(channel, target); return; } else { Logger.Log.Write("UNHANDLED TWITCH NOTIFICATION: " + channel.name + ":" + notification, ConsoleColor.Yellow); } }