Move plugin code to the proper spot

This commit is contained in:
Nick Chambers 2021-07-12 00:38:59 -05:00 committed by Nick Chambers
parent 364076ef6a
commit 9088b4f799
1 changed files with 52 additions and 52 deletions

104
rowbot
View File

@ -615,6 +615,58 @@ irc_on_473() {
log_error "%s: %s" "${msg_args[1]}" "${msg_args[2]}"
}
###
# irc send handlers
###
irc_join() {
local chans
printf -v chans %s, "$@"
net_send "JOIN %s" "${chans%,}"
}
irc_nick() {
net_send "NICK :%s" "$1"
}
irc_ping() {
net_send "PING :%s" "$1"
}
irc_pong() {
net_send "PONG %s" "$1"
}
irc_privmsg() {
local msg=$2 msg_len
if [[ -v config[host] ]]; then
(( msg_len = 493 - (${#config[nick]} + ${#config[ident]} + ${#config[host]} + ${#1}) ))
log_debug "max message length is %d" "$msg_len"
while (( ${#msg} > msg_len )); do
net_send "PRIVMSG %s :"$'\xe2\x80\x8b'"%s" "$1" "${msg:0:$msg_len}"
log_info "<%s/%s> %s" "${config[nick]}" "$1" "${msg:0:$msg_len}"
msg=${msg:$msg_len}
done
fi
net_send "PRIVMSG %s :"$'\xe2\x80\x8b'"%s" "$1" "$msg"
log_info "<%s/%s> %s" "${config[nick]}" "$1" "$msg"
}
irc_user() {
net_send "USER %s 0 * :%s" "$1" "$2"
}
irc_who() {
if (( $# > 1 )); then
net_send "WHO %s %s" "$1" "$2"
else
net_send "WHO %s" "$1"
fi
}
###
# plugin api
###
@ -684,58 +736,6 @@ on_msg_PRIVMSG_nolog() {
fi
}
###
# irc send handlers
###
irc_join() {
local chans
printf -v chans %s, "$@"
net_send "JOIN %s" "${chans%,}"
}
irc_nick() {
net_send "NICK :%s" "$1"
}
irc_ping() {
net_send "PING :%s" "$1"
}
irc_pong() {
net_send "PONG %s" "$1"
}
irc_privmsg() {
local msg=$2 msg_len
if [[ -v config[host] ]]; then
(( msg_len = 493 - (${#config[nick]} + ${#config[ident]} + ${#config[host]} + ${#1}) ))
log_debug "max message length is %d" "$msg_len"
while (( ${#msg} > msg_len )); do
net_send "PRIVMSG %s :"$'\xe2\x80\x8b'"%s" "$1" "${msg:0:$msg_len}"
log_info "<%s/%s> %s" "${config[nick]}" "$1" "${msg:0:$msg_len}"
msg=${msg:$msg_len}
done
fi
net_send "PRIVMSG %s :"$'\xe2\x80\x8b'"%s" "$1" "$msg"
log_info "<%s/%s> %s" "${config[nick]}" "$1" "$msg"
}
irc_user() {
net_send "USER %s 0 * :%s" "$1" "$2"
}
irc_who() {
if (( $# > 1 )); then
net_send "WHO %s %s" "$1" "$2"
else
net_send "WHO %s" "$1"
fi
}
###
# cleanup
###