Mercurial > hg > egg-tcls
comparison quotedb.tcl @ 597:6997201c7b71
quotedb: Clean up regexp statements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 03 Feb 2021 13:36:43 +0200 |
parents | 7f7d8048ecb5 |
children | acc2ba6be415 |
comparison
equal
deleted
inserted
replaced
596:b524a6e4be63 | 597:6997201c7b71 |
---|---|
134 | 134 |
135 if {![qdb_valid_user $ucmd $utable $upublic $unick $uchan $uhand]} { | 135 if {![qdb_valid_user $ucmd $utable $upublic $unick $uchan $uhand]} { |
136 return 0 | 136 return 0 |
137 } | 137 } |
138 | 138 |
139 if {![regexp {^\s*([0-9]+)$} $utext umatch unum]} { | 139 if {![regexp {^\s*([0-9]+)$} $utext -> unum]} { |
140 qdb_msg $ucmd $utable $upublic $unick $uchan "help_delete" | 140 qdb_msg $ucmd $utable $upublic $unick $uchan "help_delete" |
141 return 0 | 141 return 0 |
142 } | 142 } |
143 | 143 |
144 set qoverride [matchattr $uhand n] | 144 set qoverride [matchattr $uhand n] |
183 | 183 |
184 if {![qdb_valid_user $ucmd $utable $upublic $unick $uchan $uhand]} { | 184 if {![qdb_valid_user $ucmd $utable $upublic $unick $uchan $uhand]} { |
185 return 0 | 185 return 0 |
186 } | 186 } |
187 | 187 |
188 if {![regexp {^\s*([0-9]+)\s+(.+)$} $utext umatch unum uquote]} { | 188 if {![regexp {^\s*([0-9]+)\s+(.+)$} $utext -> unum uquote]} { |
189 qdb_msg $ucmd $utable $upublic $unick $uchan "help_update" | 189 qdb_msg $ucmd $utable $upublic $unick $uchan "help_update" |
190 return 0 | 190 return 0 |
191 } | 191 } |
192 | 192 |
193 set qoverride [matchattr $uhand n] | 193 set qoverride [matchattr $uhand n] |
252 if {![qdb_valid_user $ucmd $utable $upublic $unick $uchan $uhand]} { | 252 if {![qdb_valid_user $ucmd $utable $upublic $unick $uchan $uhand]} { |
253 return 0 | 253 return 0 |
254 } | 254 } |
255 | 255 |
256 set uvote 1 | 256 set uvote 1 |
257 if {$utext == "" || [regexp {^\s*(-?1)\s*$} $utext umatch uvote]} { | 257 if {$utext == "" || [regexp {^\s*(-?1)\s*$} $utext -> uvote]} { |
258 set usql "SELECT max(id) AS qid FROM ${utable}" | 258 set usql "SELECT max(id) AS qid FROM ${utable}" |
259 set uid 0 | 259 set uid 0 |
260 qdb_handle eval $usql { set uid $qid } | 260 qdb_handle eval $usql { set uid $qid } |
261 } elseif {[regexp {^\s*([0-9]+)$} $utext umatch uid]} { | 261 } elseif {[regexp {^\s*([0-9]+)$} $utext -> uid]} { |
262 } elseif {![regexp {^\s*([0-9]+)\s+(-1|1)$} $utext umatch uid uvote]} { | 262 } elseif {![regexp {^\s*([0-9]+)\s+(-1|1)$} $utext -> uid uvote]} { |
263 qdb_msg $ucmd $utable $upublic $unick $uchan "help_vote" | 263 qdb_msg $ucmd $utable $upublic $unick $uchan "help_vote" |
264 return 0 | 264 return 0 |
265 } | 265 } |
266 | 266 |
267 # Check if given quote ID exists. | 267 # Check if given quote ID exists. |
448 set utext [string trim $utext] | 448 set utext [string trim $utext] |
449 | 449 |
450 if {$utext == "" || $utext == {}} { | 450 if {$utext == "" || $utext == {}} { |
451 # No arguments, assume random query | 451 # No arguments, assume random query |
452 qdb_get $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext -1 | 452 qdb_get $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext -1 |
453 } elseif {[regexp {^(stat|stats|tilasto|tilastot)$} $utext umatch]} { | 453 } elseif {[regexp {^(stat|stats|tilasto|tilastot)$} $utext]} { |
454 # Statistics | 454 # Statistics |
455 qdb_stats $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext | 455 qdb_stats $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext |
456 } elseif {[regexp {^(last|latest|uusin|viimeisin)$} $utext umatch]} { | 456 } elseif {[regexp {^(last|latest|uusin|viimeisin)$} $utext]} { |
457 # Latest added | 457 # Latest added |
458 qdb_get $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext -2 | 458 qdb_get $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext -2 |
459 } elseif {[regexp {^([0-9]+)$} $utext umatch unum]} { | 459 } elseif {[regexp {^([0-9]+)$} $utext -> unum]} { |
460 # Numeric argument, assume id query | 460 # Numeric argument, assume id query |
461 qdb_get $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext $unum | 461 qdb_get $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext $unum |
462 } elseif {[regexp {^top\s*([0-9]+)?$} $utext umatch uargs]} { | 462 } elseif {[regexp {^top\s*([0-9]+)?$} $utext -> uargs]} { |
463 # Toplist of quotes | 463 # Toplist of quotes |
464 qdb_toplist $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext $uargs | 464 qdb_toplist $ucmd $utable $upublic $unick $uhost $uhand $uchan $utext $uargs |
465 } elseif {[regexp {^add\s*(.*)$} $utext umatch uargs]} { | 465 } elseif {[regexp {^add\s*(.*)$} $utext -> uargs]} { |
466 # Add quote | 466 # Add quote |
467 qdb_add $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs | 467 qdb_add $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs |
468 } elseif {[regexp {^del\s*([0-9]*)$} $utext umatch uargs]} { | 468 } elseif {[regexp {^del\s*([0-9]*)$} $utext -> uargs]} { |
469 # Delete quote | 469 # Delete quote |
470 qdb_delete $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs | 470 qdb_delete $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs |
471 } elseif {[regexp {^update\s*(.*)$} $utext umatch uargs]} { | 471 } elseif {[regexp {^update\s*(.*)$} $utext -> uargs]} { |
472 # Modify/update quote | 472 # Modify/update quote |
473 qdb_update $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs | 473 qdb_update $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs |
474 } elseif {[regexp {^find\s*(.*)$} $utext umatch uargs]} { | 474 } elseif {[regexp {^find\s*(.*)$} $utext -> uargs]} { |
475 # Find quote(s) | 475 # Find quote(s) |
476 qdb_find $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs | 476 qdb_find $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs |
477 } elseif {[regexp {^vote\s*(.*)$} $utext umatch uargs]} { | 477 } elseif {[regexp {^vote\s*(.*)$} $utext -> uargs]} { |
478 # Vote | 478 # Vote |
479 qdb_vote $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs | 479 qdb_vote $ucmd $utable $upublic $unick $uhost $uhand $uchan $uargs |
480 } else { | 480 } else { |
481 # Help/usage | 481 # Help/usage |
482 qdb_msg $ucmd $utable $upublic $unick $uchan "help" | 482 qdb_msg $ucmd $utable $upublic $unick $uchan "help" |