summaryrefslogtreecommitdiffstats
path: root/modules/example.bash
blob: 18937226d5e9a24d8e39e033c1a59e47001ae16e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
}