Break up the IRC magic
This commit is contained in:
parent
45ab12a482
commit
50be40354f
1 changed files with 38 additions and 35 deletions
73
rowbot
73
rowbot
|
@ -379,18 +379,43 @@ on_sys_exit_998_net() {
|
||||||
}
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
# irc magic (everything required to make the bot part of rowbot functional)
|
# annoyatron900 - keep alive process
|
||||||
###
|
###
|
||||||
|
|
||||||
magic_annoyatron900() {
|
annoyatron900() {
|
||||||
irc_ping "row your bot gently down the stream"
|
irc_ping "row your bot gently down the stream"
|
||||||
}
|
}
|
||||||
|
|
||||||
on_sys_init_999_magic() {
|
on_sys_before_999_annoyatron900() {
|
||||||
get_option chan ""
|
if [[ -v alarm_pid ]]; then
|
||||||
|
export ALARM_PID=$alarm_pid
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
on_sys_first_003_magic() {
|
on_sys_after_999_annoyatron900() {
|
||||||
|
trap annoyatron900 USR1
|
||||||
|
|
||||||
|
if [[ -v ALARM_PID ]]; then
|
||||||
|
alarm_pid=$ALARM_PID
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
on_sys_register_999_annoyatron900() {
|
||||||
|
while true; do
|
||||||
|
read -rt 10 </dev/zero
|
||||||
|
KILL -USR1 "$$"
|
||||||
|
done &
|
||||||
|
|
||||||
|
alarm_pid=$!
|
||||||
|
trap annoyatron900 USR1
|
||||||
|
log_debug "process %d is being annoying" "$alarm_pid"
|
||||||
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
# register with the server
|
||||||
|
###
|
||||||
|
|
||||||
|
on_sys_first_003_welcome() {
|
||||||
get_option nick rowbot-dev
|
get_option nick rowbot-dev
|
||||||
get_option ident rowbot
|
get_option ident rowbot
|
||||||
get_option realname rowbot
|
get_option realname rowbot
|
||||||
|
@ -399,52 +424,30 @@ on_sys_first_003_magic() {
|
||||||
irc_user "${config[ident]}" "${config[realname]}"
|
irc_user "${config[ident]}" "${config[realname]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
on_sys_before_999_magic() {
|
on_sys_init_999_welcome() {
|
||||||
if [[ -v alarm_pid ]]; then
|
get_option chan ""
|
||||||
export ALARM_PID=$alarm_pid
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
on_sys_after_999_magic() {
|
on_sys_register_999_welcome() {
|
||||||
trap magic_annoyatron900 USR1
|
|
||||||
|
|
||||||
if [[ -v ALARM_PID ]]; then
|
|
||||||
alarm_pid=$ALARM_PID
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
on_sys_register_999_magic() {
|
|
||||||
if [[ ${config[chan]} ]]; then
|
if [[ ${config[chan]} ]]; then
|
||||||
irc_join "${config[chan]}"
|
irc_join "${config[chan]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -rt 10 </dev/zero
|
|
||||||
KILL -USR1 "$$"
|
|
||||||
done &
|
|
||||||
|
|
||||||
alarm_pid=$!
|
|
||||||
trap magic_annoyatron900 USR1
|
|
||||||
log_debug "process %d is being annoying" "$alarm_pid"
|
|
||||||
config[nick]=${msg_args[0]}
|
config[nick]=${msg_args[0]}
|
||||||
irc_who "${config[nick]}" %%uht,42
|
irc_who "${config[nick]}" %%uht,42
|
||||||
}
|
}
|
||||||
|
|
||||||
on_msg_354_magic() {
|
###
|
||||||
|
# magic required to make privmsg work
|
||||||
|
###
|
||||||
|
|
||||||
|
on_msg_354_privmagic() {
|
||||||
if (( msg_args[1] == 42 )); then
|
if (( msg_args[1] == 42 )); then
|
||||||
log_debug "received the identifying who"
|
log_debug "received the identifying who"
|
||||||
config[ident]=${msg_args[2]} config[host]=${msg_args[3]}
|
config[ident]=${msg_args[2]} config[host]=${msg_args[3]}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
on_sys_exit_997_magic() {
|
|
||||||
log_debug "shutting down annoyatron900"
|
|
||||||
|
|
||||||
if [[ -v alarm_pid ]] && is_running "$alarm_pid"; then
|
|
||||||
kill -STOP "$alarm_pid"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# irc receive handlers
|
# irc receive handlers
|
||||||
###
|
###
|
||||||
|
|
Loading…
Reference in a new issue