Skip to content

Latest commit

 

History

History
52 lines (31 loc) · 2.47 KB

README.md

File metadata and controls

52 lines (31 loc) · 2.47 KB

Using Modules

To use modules, all you need to do is drop the module -- named similar to something.py -- into this folder and then mention it in a command.

You can mention modules in commands by surrounding the name of it in percentage: %module%

e.g. r!cmd add help %help% would create a command using the help module.

You can see a list of additional optional modules here.

Module Configs

Some modules use a config to store parameters on how they should work. Modules that use a config store it under userdata/[your Twitch ID]/modules. By default, the only configs in here will be for cmd and prefix.

It's recommended you look at the module (it will have the same name in modules, just with the .py suffix, or given Type "Python File" by Windows) in your text editor of choice to see a better description of each option before changing anything.

Some modules require configuration before they can work, e.g. the request module which requires you to grant it some credentials for interfacing with the osu! API.

Modules only create their default config when first imported, so you'll have to create a command with it first to create the file.


Creating your own custom module

For advanced users, a sample module showing most things with comments is available as sample.py.

Name the file after your module: sample.py.
You can then reference your module as the response of a command, for example, r!cmd add sample %sample%.

Your module must have a Module class that extends commands.BaseModule.

If you're overriding __init__, be sure to call BaseModule.__init__(self, bot, name).

The code that replaces %sample% in the response goes in a function called main.
You can find the TwitchBot instance as self._bot.

If your module intends to use arguments, get them by setting the consume static variable and calling self.get_args(message).
This helps bunch up arguments together, allowing multiple modules in the same command to interact predictably.

Your module can have a help message, stored in the helpmsg static variable.
Whatever it contains will be shown if the module is provided as an argument for the help command.

Otherwise, you're free to add whatever you want to the module, as long as you know how to code it.

Be very careful as this can be abused!