# HG changeset patch # User Matti Hamalainen # Date 1594120855 -10800 # Node ID 20a1b0f39f71fa06e9923848d325430f558f44c2 # Parent 461be6f596bdbebd1d115b4aaf2a138efbc33ba9 utillib: Add new helper functions. diff -r 461be6f596bd -r 20a1b0f39f71 utillib.tcl --- a/utillib.tcl Tue Jul 07 14:20:36 2020 +0300 +++ b/utillib.tcl Tue Jul 07 14:20:55 2020 +0300 @@ -68,6 +68,14 @@ } +proc utl_valid_user {uhand} { + if {$uhand != "" && $uhand != "{}" && $uhand != "*"} { + return 1 + } + return 0 +} + + # Send IRC message with given message type, splitting the # string to fit to IRCNet (etc.) max message length. proc utl_msg_do {upreferredmsg upublic unick uchan umsg} { @@ -81,6 +89,23 @@ } +proc utl_msg_args {upreferredmsg upublic unick uchan umsg {uargs {}}} { + + # Map constant tokens + set umsg [string map [list "@nick@" $unick] $umsg] + set umsg [string map [list "@chan@" $uchan] $umsg] + + # Map numeric tokens + set narg 1 + foreach marg $uargs { + set umsg [string map [list "@$narg@" $marg] $umsg] + incr narg + } + + utl_msg_do $upreferredmsg $upublic $unick $uchan $umsg +} + + # Return formatted time for given UNIX timestamp proc utl_ctime {utime} { if {$utime == "" || $utime == "*"} {