From 9088b4f79932c1ef621937b6931589f864cbd8a8 Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Mon, 12 Jul 2021 00:38:59 -0500 Subject: [PATCH] Move plugin code to the proper spot --- rowbot | 104 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/rowbot b/rowbot index 5a84812..21851ad 100755 --- a/rowbot +++ b/rowbot @@ -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 ###