Add more IRC handlers
This commit is contained in:
parent
1b3970d103
commit
99783ba792
92
rowbot
92
rowbot
|
@ -155,15 +155,6 @@ get_option dev yes
|
|||
|
||||
on_sys_first_001_bootup() {
|
||||
log_info "rowbot's pid is %d" "$$"
|
||||
get_option nick rowbot-dev
|
||||
get_option ident rowbot
|
||||
get_option realname rowbot
|
||||
}
|
||||
|
||||
on_sys_first_999_bootup() {
|
||||
log_debug "registering with the server"
|
||||
irc_nick "${config[nick]}"
|
||||
irc_user "${config[ident]}" "${config[realname]}"
|
||||
}
|
||||
|
||||
on_sys_before_999_bootup() {
|
||||
|
@ -188,7 +179,7 @@ on_sys_after_001_bootup() {
|
|||
}
|
||||
|
||||
on_sys_exit_999_bootup() {
|
||||
log_info "There’s a lot of beauty in ordinary things. Isn’t that kind of the point?"
|
||||
log_info "There's a lot of beauty in ordinary things. Isn't that kind of the point?"
|
||||
}
|
||||
|
||||
###
|
||||
|
@ -380,6 +371,15 @@ on_sys_init_999_magic() {
|
|||
get_option chan ""
|
||||
}
|
||||
|
||||
on_sys_first_003_magic() {
|
||||
get_option nick rowbot-dev
|
||||
get_option ident rowbot
|
||||
get_option realname rowbot
|
||||
log_debug "registering with the server"
|
||||
irc_nick "${config[nick]}"
|
||||
irc_user "${config[ident]}" "${config[realname]}"
|
||||
}
|
||||
|
||||
on_sys_before_999_magic() {
|
||||
if [[ -v alarm_pid ]]; then
|
||||
export ALARM_PID=$alarm_pid
|
||||
|
@ -417,17 +417,51 @@ on_sys_exit_997_magic() {
|
|||
fi
|
||||
}
|
||||
|
||||
# nick=${args[0]}
|
||||
# who "$nick" %%uht,42
|
||||
|
||||
###
|
||||
# irc receive handlers
|
||||
###
|
||||
|
||||
irc_on_ERROR() {
|
||||
log_error "${msg_args[0]}"
|
||||
exit
|
||||
}
|
||||
|
||||
irc_on_JOIN() {
|
||||
log_info "%s has joined %s" "${msg[from]}" "${msg_args[0]}"
|
||||
}
|
||||
|
||||
irc_on_KICK() {
|
||||
if (( ${#msg_args[@]} == 3 )); then
|
||||
log_info "%s has kicked %s from %s: %s" "${msg[from]}" "${msg_args[1]}" "${msg_args[0]}" "${msg_args[-1]}"
|
||||
else
|
||||
log_info "%s has kicked %s from %s" "${msg[from]}" "${msg_args[1]}" "${msg_args[0]}"
|
||||
fi
|
||||
}
|
||||
|
||||
irc_on_MODE() {
|
||||
if (( ${#msg_args[@]} == 2 )); then
|
||||
log_info "%s sets mode(s) %s on %s" "${msg[from]}" "${msg_args[1]}" "${msg_args[0]}"
|
||||
elif (( ${#msg_args[@]} > 2 )); then
|
||||
log_info "%s: %s sets mode(s) %s" "${msg_args[0]}" "${msg[from]}" "${msg_args[*]:1}"
|
||||
fi
|
||||
}
|
||||
|
||||
irc_on_NICK() {
|
||||
log_info "%s has changed their name to %s" "${msg[from]}" "${msg_args[0]}"
|
||||
}
|
||||
|
||||
irc_on_NOTICE() {
|
||||
log_info "[%s/%s] %s" "${msg[from]}" "${msg_args[0]}" "${msg_args[1]}"
|
||||
}
|
||||
|
||||
irc_on_PART() {
|
||||
if (( ${#msg_args[@]} > 1 )); then
|
||||
log_info "%s has left %s: %s" "${msg[from]}" "${msg_args[0]}" "${msg_args[1]}"
|
||||
else
|
||||
log_info "%s has left %s" "${msg[from]}" "${msg_args[0]}"
|
||||
fi
|
||||
}
|
||||
|
||||
irc_on_PING() {
|
||||
irc_pong "${msg_args[1]}"
|
||||
log_debug "received ping: %s" "${msg_args[0]}"
|
||||
|
@ -437,12 +471,40 @@ irc_on_PONG() {
|
|||
log_debug "received pong: %s" "${msg_args[1]}"
|
||||
}
|
||||
|
||||
irc_on_PRIVMSG() {
|
||||
log_info "<%s/%s> %s" "${msg[from]}" "${msg_args[0]}" "${msg_args[1]}"
|
||||
}
|
||||
|
||||
irc_on_TOPIC() {
|
||||
log_info "%s has changed the topic for %s: %s" "${msg[from]}" "${msg_args[0]}" "${msg_args[1]}"
|
||||
}
|
||||
|
||||
irc_on_QUIT() {
|
||||
log_info "%s has disconnected: %s" "${msg[from]}" "${msg_args[0]}"
|
||||
}
|
||||
|
||||
irc_on_001() {
|
||||
log_info %s "${msg_args[1]}"
|
||||
run_callbacks on_sys_register_
|
||||
run_callbacks on_register_
|
||||
}
|
||||
|
||||
irc_on_002() {
|
||||
log_info %s "${msg_args[1]}"
|
||||
}
|
||||
|
||||
irc_on_003() {
|
||||
log_info %s "${msg_args[1]}"
|
||||
}
|
||||
|
||||
irc_on_004() {
|
||||
log_debug "%s " "${msg_args[@]:1}"
|
||||
}
|
||||
|
||||
irc_on_005() {
|
||||
log_debug "received inotify specs"
|
||||
}
|
||||
|
||||
###
|
||||
# irc send handlers
|
||||
###
|
||||
|
@ -461,6 +523,10 @@ irc_ping() {
|
|||
net_send "PING :%s" "$1"
|
||||
}
|
||||
|
||||
irc_pong() {
|
||||
net_send "PONG %s" "$1"
|
||||
}
|
||||
|
||||
irc_user() {
|
||||
net_send "USER %s 0 * :%s" "$1" "$2"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue