Trotbot Redux: Extensible API

Semi-free Trotbot Redux: Extensible API 1.0

Trotbot Redux

Summary
Alone, this is a program that connects to Twitch chat rooms with the required user credentials just as any other IRC client would. It also allows for chatting through the console from the bot. Though, seeing as that would not be efficient, there are hooks in the program that allow for building plugins to automate tasks.

Details
It takes some knowledge of the programming language C# upon which this bot is build off of. It also requires a basic understanding of the IRC protocol for use of commands such as how to send messages down the pipeline. IRC information in detail can be found here: http://www.faqs.org/rfcs/rfc2812.html. This chat bot is built using .NET Core meaning it is compatible with Linux distros (not tested, just conjecture).

Plugin Examples
These are provided within the download package as pre-built plugins.
On Join raw
C#:
[ApiVersion(0, 1)]
    public class Plugin : TwitchBot
    {
        public override Version Version => new Version(1, 0, 0, 0);
        public override string Name => "Basic commands";

        public override void Initialize()
        {
            Data = new DataStore("command_data");
            ChatRoom.UserCommandEvent += OnCommand;
        }
        public override void Dispose()
        {
            ChatRoom.UserCommandEvent -= OnCommand;
            Data.WriteToFile();
        }

        private void OnCommand(object sender, ChatRoom.CommandEventArgs e)
        {
            ChatRoom chat = ChatRoom.Instance;
            string prefix = (Send + channel + " @" + e.User + " :").Normalize();
            string prefix2 = (Send + channel + " :").Normalize();
            string cmd = "";
            string command = e.Message.Substring(1).ToLower().Normalize();

            if (Data.BlockExists(command))
            {
                chat.SendMessage(prefix2 + Data.GetBlock(command).GetValue(Parameters[1]));
                return;
            }
            if (channel == e.User)
            {
                if (command.StartsWith("create"))
                {
                    if (!command.Contains(" "))
                    {
                        chat.SendMessage(prefix2 + "There is no command title, therefore this command was ignored.");
                        return;
                    }
                    cmd = command.Substring(command.IndexOf(" ") + 1);
                    if (cmd.Contains(" "))
                    {
                        chat.SendMessage(prefix2 + "Command title contains a space, therefore this command was ignored.");
                        return;
                    }
                    if (!Data.BlockExists(cmd))
                    {
                        Data.NewBlock(Parameters, cmd);
                        chat.SendMessage(prefix2 + "Command [" + cmd + "] made. Now use the command <edit <command name>> to change it's contents.");
                    }
                    else
                    {
                        chat.SendMessage(prefix2 + "This command has already been made.");
                    }
                    return;
                }
                else if (command.StartsWith("edit"))
                {
                    if (!command.Contains(" "))
                        return;
                    string[] split = command.Split(' ');
                    if (split.Length < 3)
                    {
                        chat.SendMessage(prefix2 + "Command edit using insufficient parameters.");
                        return;
                    }
                    cmd = split[1];
                    if (Data.BlockExists(cmd))
                    {
                        Block block = Data.GetBlock(cmd);
                        block.WriteValue(Parameters[1], e.Message.Substring("edit".Length + cmd.Length + 3));
                        chat.SendMessage(prefix2 + "Command description modified.");
                    }
                    else
                    {
                        chat.SendMessage(prefix2 + "Command does not exist.");
                    }
                }
            }
        }
}
Previews
Console view:
in-app.png


Chat Commands and Welcome plugins in Twitch's chat:
t-chat.png
  • Like
Reactions: gatekeeper1122
Author
700hours
Downloads
127
Views
1,078
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from 700hours

Latest updates

  1. Further Support Information

    Hey OBS community, While programming for users has been worthwhile as of late, this particular...
  2. Re-versioned: v1.0

    Re-versioning Update An IRC-based chat bot API for connecting to `Twitch.tv`s chat room...
  3. GUI Hotfix

    Hello, This update is for fixing the GUI chat auto scrolling from stationary when text scrolls...
Top