; ============================================================================= ; Simple ZNC buffer playback handler script r16 ; by László Tamás Szabó /// Ryck @ IRCnet, Freenode or EFnet ; ; Report any bugs, ideas or suggestions to laszlo.tamas.szabo@gmail.com ; ; This script formats the messages received from ZNC and its buffextras module ; to look like the default mIRC messages. ; You can modify its output and integrate it into other scripts by replacing ; znc_*_msg aliases with custom ones. ; ============================================================================= ; /// ChangeLog /// ; r16: ; - Added menu item to enable / disable highlighting ; - A few fixes regarding the handling of nick!ident@hostname strings ; ============================================================================= ; ====== ; events ; ====== on 1:load:{ echo -sc info * Setting up ZNC buffer playback handler... auser znc *!*@znc.in set %znc.enabled 1 set %znc.timestamps 1 set %znc.highlight 1 } on ^znc:text:*:#:{ if (%znc.enabled == 1) { if ($nick == ***) { if ($1- == Buffer Playback...) { set -e %znc.playback. [ $+ [ $cid ] $+ . $+ [ $chan ] ] 1 } if ($1- == Playback Complete.) { unset %znc.playback. [ $+ [ $cid ] $+ . $+ [ $chan ] ] } } elseif ($nick == *buffextras) { if ($3 == joined) { znc_join_msg $1 $2 } elseif ($3 == parted) { znc_part_msg $1 $2 } elseif ($3 == quit) { znc_quit_msg $1 $2 $6- } elseif (($5 == known) && ($6 == as)) { znc_nickchange_msg $1 $2 $7 } elseif (($3 == set) && ($4 == mode:)) { znc_modechange_msg $1 $2 $5- } elseif (($3 == changed) && ($5 == topic)) { znc_topicchange_msg $1 $2 $7- } elseif (($3 == kicked) && ($5 == Reason:)) { znc_kick_msg $1 $2 $4 $6- } haltdef } } } on ^*:text:*:#:{ if ((%znc.enabled == 1) && ($znc_getplayback == 1)) { znc_text_msg $1 $nick $2- haltdef } } on ^*:action:*:#:{ if ((%znc.enabled == 1) && ($znc_getplayback == 1)) { znc_action_msg $1 $nick $2- haltdef } } on ^*:notice:*:#:{ if ((%znc.enabled == 1) && ($znc_getplayback == 1)) { znc_notice_msg $1 $nick $chan $2- haltdef } } on *:disconnect:{ unset %znc.playback. [ $+ [ $cid ] $+ * ] } ; ============= ; menubar items ; ============= menu menubar { ZNC buffer playback . $znc_menuitem(%znc.enabled) playback handler:znc_toggle znc.enabled . $znc_menuitem(%znc.timestamps) timestamps:znc_toggle znc.timestamps . $znc_menuitem(%znc.highlight) highlighting:znc_toggle znc.highlight } alias znc_toggle { if ([ % $+ [ $1 ] ] == 1) { set [ % $+ [ $1 ] ] 0 } | else { set [ % $+ [ $1 ] ] 1 } } alias znc_menuitem { if ($1 == 1) { return Disable } | else { return Enable } } ; ================================== ; override these for custom messages ; ================================== ; znc_text_msg [timestamp] [nick] [message] ; znc_action_msg [timestamp] [nick] [message] ; znc_notice_msg [timestamp] [nick] [channel] [message] ; znc_join_msg [timestamp] [nick!ident@host] ; znc_part_msg [timestamp] [nick!ident@host] ; znc_quit_msg [timestamp] [nick!ident@host] [message] ; znc_nickchange_msg [timestamp] [nick!ident@host] [newnick] ; znc_modechange_msg [timestamp] [nick!ident@host] [list_of_modes] ; znc_topicchange_msg [timestamp] [nick!ident@host] [topic] ; znc_kick_msg [timestamp] [nick!ident@host] [kicked_nick] [reason] alias znc_text_msg { echo $znc_gethighlight $chan $znc_timestamp($1) < $+ $2 $+ > $3- } alias znc_action_msg { echo $znc_gethighlight $+ -c action $chan $znc_timestamp($1) * $2 $3- } alias znc_notice_msg { echo $znc_gethighlight $+ -c notice $chan $znc_timestamp($1) - $+ $2 $+ : $+ $3 $+ - $4- } alias znc_join_msg { echo $znc_gethighlight $+ -c join $chan $znc_timestamp($1) * Joins: $znc_getnick($2) ( $+ $znc_getidenthost($2) $+ ) } ; NOTE: unlike quit messages buffextras module ignores part messages! alias znc_part_msg { echo $znc_gethighlight $+ -c part $chan $znc_timestamp($1) * Parts: $znc_getnick($2) ( $+ $znc_getidenthost($2) $+ ) $3- } alias znc_quit_msg { echo $znc_gethighlight $+ -c quit $chan $znc_timestamp($1) * Quits: $znc_getnick($2) ( $+ $znc_getidenthost($2) $+ ) $3- } alias znc_nickchange_msg { echo $znc_gethighlight $+ -c nick $chan $znc_timestamp($1) * $znc_getnick($2) is now known as $3 } alias znc_modechange_msg { echo $znc_gethighlight $+ -c mode $chan $znc_timestamp($1) * $znc_getnick($2) sets mode: $3- } alias znc_topicchange_msg { echo $znc_gethighlight $+ -c topic $chan $znc_timestamp($1) * $znc_getnick($2) changes topic to ' $+ $3- $+ ' } alias znc_kick_msg { echo $znc_gethighlight $+ -c kick $chan $znc_timestamp($1) * $3 was kicked by $znc_getnick($2) $4- } ; ============================ ; identifiers for internal use ; ============================ alias znc_timestamp { if (%znc.timestamps == 1) return $1 | else return $null } alias znc_getplayback { return %znc.playback. [ $+ [ $cid ] $+ . $+ [ $chan ] ] } alias znc_gethighlight { if ((%znc.highlight == 1) && ($nick != $me)) return -l | else return $null } alias znc_getnick { if ($pos($1, !, 0) != 0) return $left($1, $calc($pos($1, !, 1) - 1)) else if ($pos($1, @, 0) != 0) return $left($1, $calc($pos($1, @, 1) - 1)) else return $1 } alias znc_getident { if ($pos($1, !, 0) == 0) return $null var %s, %n %s = $pos($1, !, 1) + 1 if ($pos($1, @, 0) == 0) %n = $len($1) - %s + 1 else %n = $pos($1, @, 1) - %s return $mid($1, %s, %n) } alias znc_gethost { if ($pos($1, @, 0) == 0) return $null else return $right($1, $calc($len($1) - $pos($1, @, 1))) } alias znc_getidenthost { if ($pos($1, !, 0) != 0) return $right($1, $calc($len($1) - $pos($1, !, 1))) else if ($pos($1, @, 0) != 0) return $right($1, $calc($len($1) - $pos($1, @, 1))) else return $null }