public void onChatMessage(Channel channel, User sender, string message) { if(message.IndexOf('!') == 0) { string[] split = message.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); string command = split[0].Substring(1); string payload = ""; if(split.Length > 1) { payload = split[1]; } handleCommand(command, payload, sender, channel); } }
public User(string nick, Channel chan) { _nickname = nick; _channel = chan; _permissions = new List<PermissionLevel>(); _messagesSent = 0; //Everybody is a user! Or are they? iunno AddPermission(PermissionLevel.User); //Hackish way of determining who the streamer is :( if (chan.name.ToLower().Equals("#" + nick.ToLower())) AddPermission(PermissionLevel.Streamer); //Add us to the channel list of users chan.AddUser(this); }
public Channel JoinChannel(string channel) { if (channel.IndexOf('#') != 0) { channel = "#" + channel; } if (ircConnection.Connected) { //Join the channel Logger.Log.Write("Joining " + channel + "...", ConsoleColor.DarkGray); ircConnection.Sender.Join(channel, true); if (GetChannelByName(channel) != null) { //Whoa! We already exist? Logger.Log.Write("Channel " + channel + " exists already?"); return GetChannelByName(channel); } Channel newchannel = new Channel(channel, this); //Now make a user object for ourself. We're still a user, are we not? User me = new User(ircArgs.Nick, newchannel); newchannel.botuser = me; //Add this channel to watch! channels.Add(newchannel); return newchannel; } else { Logger.Log.Write("Unable to join channel without a connection"); return null; } }
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); } }
private void handleCommand(string command, string payload, User sender, Channel channel) { switch(command) { case "chat": case "subs": case "plebs": spammerino(command, channel); break; case "me": spammerino(sender.Nickname, channel); break; case "hi": if (payload.ToLower().Contains("nebez")) { spammerino(sender.Nickname, channel, true); } else { spammerino(payload, channel); } break; case "repeat": channel.SendMessage(payload); break; case "shutdown": if(sender.Nickname.ToLower().Equals("nebezb")) { channel.SendMessage("goodbye Kappa"); bot.Stop(); } break; case "join": if(sender.Nickname.ToLower().Equals("nebezb")) { bot.JoinChannel(payload); } break; case "leave": if(sender.Nickname.ToLower().Equals("nebezb")) { if (payload.Length > 0) bot.LeaveChannel(payload); else bot.LeaveChannel(channel.name); } break; case "spammerino": if(sender.Nickname.ToLower().Equals("nebezb")) { spammerinoMessage = payload; channel.SendMessage("Kappa"); } break; case "channels": if(sender.Nickname.ToLower().Equals("nebezb")) { channel.SendMessage(String.Join(", ", bot.channels.Select(c => c.name))); } break; } }
public void onUserAction(Channel channel, User sender, string action) { //triggered when people use the /me command. }
public void onNewSubscriber(Channel channel, User subscriber) { Logger.Log.Write("new sub: " + subscriber.Nickname, ConsoleColor.Blue); }
private void spammerino(string target, Channel channel, bool trollerino = false) { string msg = String.Format(spammerinoMessage, target); if(trollerino) { msg += " Keepo"; } channel.SendMessage(msg); }