diff options
author | clsr <clsr@clsr.net> | 2017-03-22 21:07:10 +0100 |
---|---|---|
committer | clsr <clsr@clsr.net> | 2017-03-22 21:07:10 +0100 |
commit | ff2bc5d0931d4a460d4d74183b6f9dd9394c40a0 (patch) | |
tree | 13dbf5a1395ae4e3dcd458bf114d962b28a8657c /modules/example.bash | |
download | mbibot-0.1.0.tar.gz mbibot-0.1.0.zip |
Initial commitv0.1.0
Diffstat (limited to 'modules/example.bash')
-rw-r--r-- | modules/example.bash | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/modules/example.bash b/modules/example.bash new file mode 100644 index 0000000..1893722 --- /dev/null +++ b/modules/example.bash @@ -0,0 +1,69 @@ +# modules/example.bash +# +# Provides example handlers for an ircbot.bash module. +# This file is sourced by ircbot.bash when the module is loaded. +# Any handlers may be omitted in modules if they're not used. +# If an event matches multiple handlers, they're all called (e.g. on_readmsg is +# always called alongside on_privmsg). +# +# Global variables: +# +# IRCBOT_HOST: IRC server address +# IRCBOT_PORT: IRC server port +# IRCBOT_NICK: bot nick +# IRCBOT_LOGIN: bot login name +# IRCBOT_REALNAME: bot realname +# IRCBOT_MODULE: current module the bot is running + + +if [ -z "$IRCBOT_MODULE" ]; then + printf "error: %s is a module for ircbot.bash and should not be run separately\n" "$0" + exit 1 +fi + + +# on_connect is called when the bot connects (or reconnects) to the server +on_connect() { # no args +} + +# on_disconnect is called when the bot disconnects from the server +on_disconnect() { # no args +} + +# on_readmsg is called whenever a message is read from the IRC server +on_readmsg() { # args: $1 - raw message, $2 - source, $3 - command, $4... - args +} + +# on_sendmsg is called whenever sendmsg is used to send IRC messages +# If it returns non-zero, the sendmsg itself is aborted. +# Be careful not to create infinite sendmsg/on_sendmsg loops. +on_sendmsg() { # args: $1 - raw message, $2 - command, $3... - args +} + +# on_privmsg is called whenever a PRIVMSG is received +on_privmsg() { # args: $1 - source, $2 - channel/target, $3 - message +} + +# on_dm is called whenever a PRIVMSG direct (not channel) message is received +on_dm() { # args: $1 - source, $2 - message +} + +# on_ctcp is called whenever a CTCP PRIVMSG direct (not channel) message is received +on_ctcp() { # args: $1 - source, $2 - CTCP command, $3 - CTCP argument +} + +# on_self_join is called whenever the bot successfully joins a channel +on_self_join() { # args: $1 - channel +} + +# on_self_kick is called whnever the bot is kicked from a channel +on_self_kick() { # args: $1 - source, $2 - channel, $3 - kick message +} + +# on_self_part is called whenever the bot parts a channel +on_self_part() { # args: $1 - channel, $2 - part message +} + +# on_self_invite is called whenever the bot is invited into a channel +on_self_invite() { # args: $1 - source, $2 - channel +} |