Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- There are a couple different types of hooks that can be used for plugins in Skybot. The most common one is the command hook, which takes a .command as input, checks that it's a command and if it is it attempts to run it.
- Example of command:
- from util import hook
- @hook.command('h')
- @hook.command(autohelp=False)
- def hello_world(inp):
- """Returns 'Hello World' when command matches."""
- return "Hello World"
- That specifies an 'h' command, and a 'hello_world' command, if either of those are found it will run the plugin.
- ---
- Another type of hook is the regex hook, it takes a regex and if any string output in the channel matches that regex it will attempt to run the plugin.
- Example of regex:
- import re
- from util import hook
- hello_re = ('hello world', re.I)
- @hook.regex(*karma_re)
- def hello_world(inp):
- """Returns 'Hello World' when regex matches"""
- return "Hello World"
- That specifies a 'hello world' regex, that is case insensitive. If the regex is matched in any string output in the channel, it will attempt to run the plugin.
- ---
- Yet another type of a hook is the event hook, it takes an IRC event such as KICK, INVITE OR PRIVMSG and if any of those happens it will attempt to run the plugin
- Example of event:
- from util import hook
- #autorejoin channels
- @hook.event('KICK')
- def rejoin(paraml, conn=None):
- if paraml[1] == conn.nick:
- if paraml[0].lower() in conn.channels:
- conn.join(paraml[0])
- That specifies a 'KICK' event, so when skybot is kicked it will attempt to rejoin the channel.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement