No Libraries Required!!! This project uses all native C++11 code.
Drop the files into a directory and open a terminal. cd to the directory and run the command 'cmake . && make' to compile, then run the code with ./PhantomBot
Drop the files into a directory. Open Visual Studio and add all of the files to a project to compile. Run the compiled executable.
There are two bot config files you can use.
This is a very basic Twitch IRC bot with a very flexible and easy to navigate code-base. At it's core, this bot has the following features:
As mentioned in the prior section, this bot has a very easy to use custom chat command interface. To create a custom chat command, follow the below instructions.
First and foremost, create a new C++ Header file, it would help you to follow the ccmd_x.h naming convention as not to differentiate from the other files in that directory. The bot uses a abstract class instance named CustomCommand, from which you will need to inherit. The class has a pure virtual function void Fire(string input) which must be overriden. At the most basic, here is a sample instance to use:
/**
ccmd_mycommand.h
PhantomBot Project
By: Robert F. (Phantom139)
**/
#ifndef _CCMD_MYCOMMAND_H
#define _CCMD_MYCOMMAND_H
#include "CustomCommands.h"
class Command_MyCommand : public CustomCommand {
public:
/* Public Class Methods */
//Constructor
Command_MyCommand() : CustomCommand() { }
//Destructor
virtual ~Command_MyCommand() { }
//Run the command
virtual void Fire(string input) {
string response = Lib::formatChatMessage("Hello World!!!");
TwitchCommandLimit::fetchInstance().AddCommand(response);
}
};
#endif //_CCMD_MYCOMMAND_H
Once you have created a custom command, you'll need to add it to the command parser, which is located in the chatCommandDefinitions.h file in the base directory. Inside this file, you'll see a group of header include statements which point to the commands included with this bot, you'll need to add your header file, like so:
//Headers to all of your custom commands (Insert the path(s) to your custom command files here)
#include "CustomCommands/ccmd_time.h"
#include "CustomCommands/ccmd_isadmin.h"
#include "CustomCommands/ccmd_mycommand.h" //<--- ADD YOUR COMMAND HERE
Finally in the class instance below, you'll need to tell the bot to trigger your custom command upon a message. We'll use !hello for our example here, to do so, scroll down and add your command to the bot like so:
//Initalize the instance
void init() {
if(initialized == true) {
return;
}
initialized = true;
CustomCommandManager::fetchInstance().AddCommand("!time", new Command_Time());
CustomCommandManager::fetchInstance().AddCommand("!isadmin", new Command_IsAdmin());
CustomCommandManager::fetchInstance().AddCommand("!hello", new Command_MyCommand());
}
And that's about it! From this, you should be able to make pretty much anything your coding capabilities allow you to do. Best of luck!
Please report and bugs or problems on the Issues page here. Please use the flags appropriately. Duplicate or non-problem bugs will be removed.