# HG changeset patch # User Matti Hamalainen # Date 1687535318 -10800 # Node ID bd7f06c8a515dd43d56158345b57bbc867004f33 # Parent fd45c52d4297c9322dac7c2505715952e27d38e8 quotedb: Cleanups. Rename some proc arguments and variables for clarity. diff -r fd45c52d4297 -r bd7f06c8a515 quotedb.tcl --- a/quotedb.tcl Fri Jun 23 17:24:32 2023 +0300 +++ b/quotedb.tcl Fri Jun 23 18:48:38 2023 +0300 @@ -106,19 +106,19 @@ #------------------------------------------------------------------------- -proc qdb_add {ucmd utable upublic unick uhost uhand uchan utext} { +proc qdb_add {ucmd utable upublic unick uhost uhand uchan uargs} { global qdb_handle if {![qdb_valid_user $ucmd $utable $upublic $unick $uchan $uhand]} { return 0 } - if {$utext == "" || $utext == {}} { + if {$uargs == "" || $uargs == {}} { qdb_msg $ucmd $utable $upublic $unick $uchan "help_add" return 0 } - set usql "INSERT INTO $utable (utime,utext,user,host,chan) VALUES ([unixtime], '[utl_escape $utext]', '[utl_escape $uhand]', '[utl_escape $uhost]', '[utl_escape $uchan]')" + set usql "INSERT INTO $utable (utime,utext,user,host,chan) VALUES ([unixtime], '[utl_escape $uargs]', '[utl_escape $uhand]', '[utl_escape $uhost]', '[utl_escape $uchan]')" if {![qdb_sql_exec $ucmd $utable $upublic $unick $uchan $usql]} { return 0 } @@ -129,7 +129,7 @@ # if {![qdb_sql_exec $ucmd $utable $upublic $unick $uchan $usql]} { return 0 } ### Log some data - qdb_log "Added ${utable} #${quoteID} (${unick}/${uhand}@${uchan}): ${utext}" + qdb_log "Added ${utable} #${quoteID} (${unick}/${uhand}@${uchan}): ${uargs}" ### Report success to user qdb_msg $ucmd $utable $upublic $unick $uchan "add_success" [list $quoteID] @@ -138,7 +138,7 @@ #------------------------------------------------------------------------- -proc qdb_delete {ucmd utable upublic unick uhost uhand uchan utext} { +proc qdb_delete {ucmd utable upublic unick uhost uhand uchan uargs} { global qdb_handle qdb_max_deltime set maxdiff [expr $qdb_max_deltime * 60] @@ -147,7 +147,7 @@ return 0 } - if {![regexp {^\s*([0-9]+)$} $utext -> unum]} { + if {![regexp {^\s*([0-9]+)$} $uargs -> unum]} { qdb_msg $ucmd $utable $upublic $unick $uchan "help_delete" return 0 } @@ -187,7 +187,7 @@ #------------------------------------------------------------------------- -proc qdb_update {ucmd utable upublic unick uhost uhand uchan utext} { +proc qdb_update {ucmd utable upublic unick uhost uhand uchan uargs} { global qdb_handle qdb_max_modtime set maxdiff [expr $qdb_max_modtime * 60] @@ -196,7 +196,7 @@ return 0 } - if {![regexp {^\s*([0-9]+)\s+(.+)$} $utext -> unum uquote]} { + if {![regexp {^\s*([0-9]+)\s+(.+)$} $uargs -> unum uquote]} { qdb_msg $ucmd $utable $upublic $unick $uchan "help_update" return 0 } @@ -232,7 +232,7 @@ #------------------------------------------------------------------------- -proc qdb_toplist {ucmd utable upublic unick uhost uhand uchan utext unum} { +proc qdb_toplist {ucmd utable upublic unick uhost uhand uchan uargs unum} { global qdb_handle global qdb_toplist_min qdb_toplist_max @@ -257,7 +257,7 @@ #------------------------------------------------------------------------- -proc qdb_vote {ucmd utable upublic unick uhost uhand uchan utext} { +proc qdb_vote {ucmd utable upublic unick uhost uhand uchan uargs} { global qdb_handle if {![qdb_valid_user $ucmd $utable $upublic $unick $uchan $uhand]} { @@ -265,12 +265,12 @@ } set qvote "+" - if {$utext == "" || [regexp {^\s*(\+|\-)\s*$} $utext -> qvote]} { + if {$uargs == "" || [regexp {^\s*(\+|\-)\s*$} $uargs -> qvote]} { set usql "SELECT max(id) AS qid FROM ${utable}" set uid 0 qdb_handle eval $usql { set uid $qid } - } elseif {[regexp {^\s*([0-9]+)$} $utext -> uid]} { - } elseif {![regexp {^\s*([0-9]+)\s+(\+|\-)$} $utext -> uid qvote]} { + } elseif {[regexp {^\s*([0-9]+)$} $uargs -> uid]} { + } elseif {![regexp {^\s*([0-9]+)\s+(\+|\-)$} $uargs -> uid qvote]} { qdb_msg $ucmd $utable $upublic $unick $uchan "help_vote" return 0 } @@ -353,7 +353,7 @@ #------------------------------------------------------------------------- -proc qdb_stats {ucmd utable upublic unick uhost uhand uchan utext} { +proc qdb_stats {ucmd utable upublic unick uhost uhand uchan uargs} { global qdb_handle set usql "SELECT count(*) AS nvotes FROM ${utable}_votes" @@ -398,7 +398,7 @@ #------------------------------------------------------------------------- -proc qdb_find {ucmd utable upublic unick uhost uhand uchan utext} { +proc qdb_find {ucmd utable upublic unick uhost uhand uchan uargs} { global qdb_handle qdb_showmax_pub qdb_showmax_priv # Limit results based on public/private @@ -409,10 +409,10 @@ } ### Parse the given command - qdb_log "${unick}/${uhand}/${uchan} searched ${utable}: '${utext}'" + qdb_log "${unick}/${uhand}/${uchan} searched ${utable}: '${uargs}'" set fpatlist {} - set ftokens [::textutil::split::splitx $utext {\s+}] + set ftokens [::textutil::split::splitx $uargs {\s+}] foreach ftoken $ftokens { set fprefix [string range $ftoken 0 0] set fpattern [string range $ftoken 1 end]