# HG changeset patch # User Matti Hamalainen # Date 1638066018 -7200 # Node ID 5163d582e3964554900eee6c6207857a622edeff # Parent 7897b795480b90499b60920b888dff4eb436bbc2 quotedb: Change voting a bit. diff -r 7897b795480b -r 5163d582e396 config.quotedb.example --- a/config.quotedb.example Sun Oct 10 20:52:20 2021 +0300 +++ b/config.quotedb.example Sun Nov 28 04:20:18 2021 +0200 @@ -120,13 +120,15 @@ "sql_error" "Virhe sörkittäessä @name@-tietokantaa. uliskaa." - "fmt_get" "#@1@: @2@ (@3@@@4@, @5@)" + "fmt_get" "#@1@: @2@ (@3@/@4@, @5@)" - "fmt_search" "#@1@: @2@ (@3@@@4@)" + "fmt_search" "#@1@: @2@ (@3@/@4@)" "no_matches" "@name@-haku ei tuottanut tuloksia." - "you_voted" "Äänestit @name@ #@1@ -> @2@, arvosana nyt @3@" - "vote_updated" "@name@-äänesi #@1@ päivitetty -> @2@, arvosana nyt @3@" + "you_voted" "Äänestit @name@ #@1@ @2@, arvosana nyt @3@" + "vote_updated" "@name@-äänesi #@1@ päivitetty @2@, arvosana nyt @3@" + "vote_up" "+" + "vote_down" "-" "add_success" "@name@-tietokantaa sörkitty (#@1@), kiitos." @@ -147,7 +149,7 @@ "help_add" "@cmd@ add " "help_update" "@cmd@ update " "help_delete" "@cmd@ del " - "help_vote" "@cmd@ vote \[\[\] \[1|-1\]\]" + "help_vote" "@cmd@ vote \[\[\] \[+|-\]\]" "help_find" "@cmd@ find [hakuparametrit] -- \[+\]sana | -sana | %käyttäjänimi" "quote_deleted" "@name@ #@1@ poistettu@2@." diff -r 7897b795480b -r 5163d582e396 quotedb.tcl --- a/quotedb.tcl Sun Oct 10 20:52:20 2021 +0300 +++ b/quotedb.tcl Sun Nov 28 04:20:18 2021 +0200 @@ -264,17 +264,25 @@ return 0 } - set uvote 1 - if {$utext == "" || [regexp {^\s*(-?1)\s*$} $utext -> uvote]} { + set qvote "+" + if {$utext == "" || [regexp {^\s*(\+|\-)\s*$} $utext -> 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+(-1|1)$} $utext -> uid uvote]} { + } elseif {![regexp {^\s*([0-9]+)\s+(\+|\-)$} $utext -> uid qvote]} { qdb_msg $ucmd $utable $upublic $unick $uchan "help_vote" return 0 } + if {$qvote == "-"} { + set qvote [qdb_qm $utable "vote_down"] + set uvote -1 + } else { + set qvote [qdb_qm $utable "vote_up"] + set uvote 1 + } + # Check if given quote ID exists. set uresults 0 set usql "SELECT id AS qid FROM ${utable} WHERE id=$uid" @@ -292,7 +300,7 @@ if {[qdb_sql_exec $ucmd $utable $upublic $unick $uchan $usql]} { set urating [qdb_get_rating_for_id $utable $uid] qdb_log "${uhand} changed vote to ${uvote} on #${uid} / ${utable}, total ${urating}" - qdb_msg $ucmd $utable $upublic $unick $uchan "vote_updated" [list $uid $uvote $urating] + qdb_msg $ucmd $utable $upublic $unick $uchan "vote_updated" [list $uid $qvote $urating] return 1 } else { return 0 @@ -304,7 +312,7 @@ if {[qdb_sql_exec $ucmd $utable $upublic $unick $uchan $usql]} { set urating [qdb_get_rating_for_id $utable $uid] qdb_log "${uhand} voted ${uvote} on #${uid} / ${utable}, total ${urating}" - qdb_msg $ucmd $utable $upublic $unick $uchan "you_voted" [list $uid $uvote $urating] + qdb_msg $ucmd $utable $upublic $unick $uchan "you_voted" [list $uid $qvote $urating] } }