This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

different announcement by different count

Help for those learning Tcl or writing their own scripts.
Post Reply
h
heman
Voice
Posts: 13
Joined: Sat Dec 30, 2006 3:17 pm

different announcement by different count

Post by heman »

When someone query's the db it returns announcement to irc channel: like this:
<botname> sending latest results:
(the max results is set to 10)


Now I want to let it announce how many records of that query it has found in the db, so i added to the script:

Code: Select all

    set cnt [mysqlsel $db "select count(*) from $table WHERE nm = '$text';" -list]
And changed the announcement in:
<botname> found ## results: sending latest results:"

Now what I liked to add is it will announce the ## results, someting like:
<botname> found 1 result: sending latest 1 result:"

<botname> found 5 result: sending latest 5 results:"

<botname> found 23 result: sending latest 10 result:"

etc.

I was thinking to do it someting like this:

Code: Select all

    if ........ {
        putserv "PRIVMSG $chan :found $cnt result: sending latest 1 result:"
    } elseif {
      ......... {
        putserv "PRIVMSG $chan :found $cnt results: sending latest 2 results:"
    } elseif {
      ......... {
        putserv "PRIVMSG $chan :found $cnt results: sending latest 3 results:"

    etc

    } else {
      ......... {
        putserv "PRIVMSG $chan :found $cnt results: sending latest 10 result:"
    } 
But I have no idea what I have to fill in on the .......

Anyone can help me?

Thanks
d
dwickie
Halfop
Posts: 76
Joined: Sat Aug 21, 2004 8:53 am
Location: /pub/beer

Post by dwickie »

something like that?

Code: Select all

set maxresults 10
if {$cnt>=$maxresults} {
  putserv "PRIVMSG $chan :found $cnt results: sending latest $maxresults result:"
} else {
  putserv "PRIVMSG $chan :found $cnt results: sending result:"
}
h
heman
Voice
Posts: 13
Joined: Sat Dec 30, 2006 3:17 pm

Post by heman »

that seems to work to :D

Thanks
Post Reply