<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/20528" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2018-10-19T08:07:10-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/20528</id>

		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2018-10-19T08:07:10-04:00</updated>

		<published>2018-10-19T08:07:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107117#p107117</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107117#p107117"/>
		<title type="html"><![CDATA[Error!! running trivia script!!! please help]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107117#p107117"><![CDATA[
change but to set<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Fri Oct 19, 2018 8:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juggle]]></name></author>
		<updated>2018-10-19T05:06:55-04:00</updated>

		<published>2018-10-19T05:06:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107116#p107116</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107116#p107116"/>
		<title type="html"><![CDATA[Error!! running trivia script!!! please help]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107116#p107116"><![CDATA[
When i try to Run this trivia script:<br><blockquote class="uncited"><div>################################################################################<br># 3hauka.tcl<br># Copyright (c) 2001-2004 <a href="mailto:hex@faerion.oss">hex@faerion.oss</a><br>#<br># Distribution and modification are allowed provided the authorship is preserved.<br># Official website: <a href="https://he3hauka.sourceforge.net/" class="postlink">https://he3hauka.sourceforge.net/</a><br>#<br># $Id: 3hauka.tcl,v 1.3 2004/04/14 09:53:06 vhex Exp $<br>#<br>################################################################################<br><br>namespace eval tpub {<br># clear previous values<br>#array unset conf<br>#array unset channels<br><br># file with fobrosami<br>set conf(fnquestions) "[file dirname [info script]]/q.txt"<br><br># the minimum number of answers for the highscore table<br>but conf (minanswers) 5<br><br># the time through which user information is erased<br># from the database, if it did not answer a single question (in seconds)<br>set conf (maxidle) [expr 60 * 60 * 24 * 31]; # one month<br><br># work time limitation, for example: {8-12 16-18}<br>set conf(timelimit) {0-24}<br><br># bot home page address<br>set conf(url) "<a href="http://www.aizawlchat.com" class="postlink">http://www.aizawlchat.com</a>"<br># set conf(url-top) "<a href="http://quiz.forestnet.org/top.var" class="postlink">http://quiz.forestnet.org/top.var</a>"<br># set conf(url-cmd) "<a href="http://quiz.forestnet.org/#commands" class="postlink">http://quiz.forestnet.org/#commands</a>"<br><br># file, in which every minute the table of records is saved,<br># to disable the function, just comment out the line<br>set conf(scoreboard) "[file dirname [info script]]/juggle.score"<br><br>#read channel settings<br>if {[file exists [set _fname [file dirname [info script]]/main.conf]]} {<br>source $_fname<br>}<br>}<br><br>#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br><br>### Converting Russian text to lowercase<br># proc ::tpub::tolower {text} { return [string map {? ?} [string tolower $text]] }<br>proc ::tpub::tolower {text} { return [string map {? ? ? ? ? ?} [string tolower $text]] }<br><br>proc ::tpub::toupper {text} { return [string map {? ? ? ? ? ?} [string toupper $text]] }<br><br>### returns the grammatical group of the number (c) s7ream<br>proc ::tpub::numgrp {number} { switch -glob -- "$number" { *11 {return 3} *12 {return 3} *13 {return 3} *14 {return 3} *1 {return 1} *2 {return 2} *3 {return 2} *4 {return 2} default {return 3} } }<br><br>### working with channel settings<br>proc ::tpub::playground {command name {option undefined}} {<br>variable channels<br><br>switch -exact $command {<br>"exists" {<br>return [info exists channels([string tolower $name])]<br>}<br>"check" {<br>if {![info exists channels([string tolower $name])]} {<br>putlog "milW0rm: playground: bad channel $name"<br>return 0<br>}<br>return [expr { [lsearch -exact [set channels([string tolower $name])] $option] == -1 ? 0 : 1 }]<br>}<br>}<br>}<br><br>proc :: tpub :: maskhost {uhost} {<br>return [::maskhost $uhost]<br># regsub {(. + @) [^.] + (\ .. +)} $ uhost {\ 1 * \ 2} host<br>#return $host<br>}<br><br>proc ::tpub::getversion {} { variable conf<br>return "1.10"<br>}<br><br># Communicate with the server<br>proc putout {cmd dest msg} { global botnick<br>set maxlen [expr 510 - [string length "$botnick![getchanhost $botnick] $cmd $dest :"]]<br>while {$msg != ""} {<br>set text [expr {[string length $msg] &gt; $maxlen ? [string range $msg 0 [string last \040 [string range $msg 0 $maxlen]]] : $msg}]<br>putserv "$cmd $dest :$text"<br>set msg [string trim [string range $msg [string length $text] end]]<br>}<br>}<br><br>proc putmsg {nick msg} { putout PRIVMSG $nick $msg }<br>proc putnot {nick msg} { putout NOTICE $nick $msg }<br>proc putact {dest msg} { putserv "PRIVMSG $dest :\001ACTION $msg\001" }<br>proc putpvt {nick msg} { puthelp "PRIVMSG $nick :$msg" }<br><br>### gives the user information on the use of the command<br>proc ::tpub::usage {nick cmd {arg ""} {info ""}} {<br>set not "\002$cmd\002"<br>if {$arg != ""} { append not " $arg" }<br>if {$info != ""} { append not " - $info"}<br><br>set aliases ""<br>foreach item [lsort [info commands ::tpub::cmd_*]] {<br>if {[string match "return \\\[cmd_$cmd * * *\\\]" [string trim [info body $item]]]} { append aliases " [string range $item 12 end]" }<br>}<br>if {$aliases != ""} {<br>append not ". ??????:$aliases"<br>}<br><br>putnot $ nick "Parametrization: $ not"<br>return 0<br>}<br><br><br># checking the possibility of working at the moment<br>proc ::tpub::checktime {} { variable conf<br>if {![info exists conf(timelimit)]} { return 1 }<br><br>foreach item [split $conf(timelimit)] {<br># only the hour is specified, and it matches the current one<br>if {[string is int $item] &amp;&amp; [expr int($item) == int([clock format [clock seconds] -format %H])]} {<br>return 1<br>}<br><br># only the first two elements are of interest<br>if {![regexp {^(\d+(:\d+)?)?-(\d+(:\d+)?)?.*$} $item t1 t1 t2 t2]} {<br>putlog "milW0rM: wrong time interval: $item"<br>continue<br>}<br><br># Default Interval Limits<br>if {$t1 == ""} { set t1 "00:00" }<br>if {$t2 == ""} { set t2 "24:00" }<br><br># add the missing minutes<br>if {[string is int $t1]} { append t1 ":00" }<br>if {[string is int $t2]} { append t2 ":00" }<br><br># Convert to normal numbers ..<br>set t1 [expr double([string map {: .} $t1])]<br>set t2 [expr double([string map {: .} $t2])]<br><br># current time<br>set t [expr double([clock format [clock seconds] -format "%H.%M"]) ]<br><br># we get, we can play further<br>if {$t &gt;= $t1 &amp;&amp; $t &lt;= $t2} { return 1 }<br>}<br><br># not one hit ..<br>return 0<br>}<br><br># work with questions<br># question rehash - analysis file with questions, remembering the addresses available<br># question get - returns an unanswered question (if necessary<br># calling rehash if the questions are over), in the format:<br>#                {question {answer answer answer}}<br>proc ::tpub::question {cmd {text ""}} { variable conf; variable qpos<br>switch -exact -- [string tolower $cmd] {<br>"count" {<br>if {![info exists qpos]} { return 0 }<br>return [llength $qpos]<br>}<br><br>"rehash" {<br>if {[info exists qpos]} { unset qpos }<br>set qpos {}<br>set ::tpub::qcount 0<br>if {[catch {open $conf(fnquestions) r} fileID]} { return 0 }<br>while {![eof $fileID]} {<br>set pos [tell $fileID]<br>incr ::tpub::qcount<br>if {[set line [string trim [gets $fileID]]] == ""} { continue }<br>if {[string range $line 0 0] == "#"} { continue }<br>lappend qpos $pos<br>}<br>close $fileID<br>return [llength $qpos]<br>}<br><br>"get" {<br># random question<br>if {![info exists qpos] || ![llength $qpos]} {<br>putlog "Out of questions, rehashing..."<br>if {![question rehash]} {<br>putlog "No questions available, eek."<br>return {}<br>}<br>}<br>set idx [expr int(rand() * [llength $qpos])]<br>set fpos [lindex $qpos $idx]<br>set qpos [lreplace $qpos $idx $idx]<br><br>if {[catch {open $conf(fnquestions) r} fileID]} { return {} }<br>seek $fileID $fpos start<br>set line [gets $fileID]<br>set line [split [string trim $line] |]<br>set line "[toupper [string range $line 0 0]][string range $line 1 end]"<br>close $fileID<br><br>return [list [lindex $line 0] [split [lrange $line 1 end] ,]]<br>}<br><br>"find" {<br>if {$text == ""} {<br>error "wrong # args: should be \"questions find pattern\""<br>}<br>set idx -1<br>if {[catch {open $conf(fnquestions) r} fileID]} { return $idx }<br>while {![eof $fileID]} {<br>if {[string range [set line [gets $fileID]] 0 0] == "#"} { continue }<br>incr idx<br>if {[lindex [split $line |] 0] == $text} {<br>close $fileID<br>return $idx<br>}<br>}<br>close $fileID<br>return -1<br>}<br><br>"del" {<br>if {$text == ""} {<br>error "wrong # args: should be \"questions del number\""<br>}<br>if {![string is integer $text]} {<br>error "bad option \"$text\": must be an integer"<br>}<br>if {[catch {open $conf(fnquestions) r+} fileID]} { return 0 }<br>while {![eof $fileID]} {<br>set pos [tell $fileID]<br>if {[string range [gets $fileID] 0 0] == "#"} { continue }<br>if {![expr int($text)]} {<br>puts -nonewline $fileID "#"<br>close $fileID<br>return 1<br>}<br>incr text -1<br>}<br>close $fileID<br>}<br><br>"add" {<br>if {$text == ""} {<br>error "" "wrong # args: should be \"questions add question test|answer|..\""<br>}<br>if {[string first | $text] == -1} {<br>error "" "wrong question format, must be: \002question text|answer\002[|answer|...]"<br>}<br>if {[catch {open $conf(fnquestions) a} fileID]} {<br>error "" "could not open questions database for writing."<br>}<br>puts $fileID " [string trim $text]"<br>close $fileID<br>}<br><br>default {<br>error "bad option \"$cmd\": must be rehash, get, find or del"<br>}<br>}<br>return 0<br>}<br><br><br># Returns the address to add a new user<br>proc ::tpub::get_new_host {host} { variable conf<br>if {![info exists conf(static_hosts)]} {<br>return "*!$host"<br>}<br><br>foreach item $conf(static_hosts) {<br>if {[string match $item $host]} {<br>return "*!$host"<br>}<br>}<br><br>return [maskhost $host]<br>}<br><br><br># work with users<br>proc ::tpub::users {cmd {text {}}} {<br>variable conf<br><br>switch -exact -- $cmd {<br>"purge" {<br>set killed 0<br>foreach hand [userlist] {<br>if {[set xtra [getuser $hand xtra quiz]] == ""} { continue }<br><br># check if one has a channel record<br>if {[chattr $hand] != "-"} { continue }<br>foreach chan [array names channels] {<br>if {[haschanrec $hand $chan]} { continue }<br>}<br><br>array set usr $xtra<br><br># linked nick, won't remove anyways<br>if {[info exists usr(link)]} { continue }<br><br>if {(![info exists usr(answers)] || $usr(answers) &lt; $conf(minanswers)) || ([info exists usr(last)] &amp;&amp; [expr [clock seconds] - $usr(last)] &gt; $conf(maxidle))} {<br>incr killed<br>deluser $hand<br>}<br>}<br>return $killed<br>}<br><br>"list" {<br># list valid users<br>set users {}<br>foreach hand [userlist] {<br>if {[set xtra [getuser $hand xtra quiz]] == ""} { continue }<br>array unset usr<br>array set usr $xtra<br>if {[info exists usr(halt)]} { continue }<br>if {[info exists usr(last)] &amp;&amp; [expr [clock seconds] - $usr(last)] &lt; 604800 &amp;&amp; ![info exists usr(link)]} {<br>lappend users [list $hand $usr(score) [format %d.%08d $usr(score) [expr 999999 - $usr(answers)]]]<br>}<br>}<br><br># sort by place and score<br>set sorted {}<br>foreach item [lsort -real -decreasing -index 2 $users] {<br>lappend sorted [lrange $item 0 1]<br>}<br>return $sorted<br>}<br><br>"exists" {<br>return [validuser $text]<br>}<br><br>"isintop" {<br>if {$text == ""} {<br>error "" "wrong # args: should be \"users isintop user\""<br>}<br>foreach item [lrange [users list] 0 4] {<br>if {![string compare -nocase $text [lindex $item 0]]} { return 1 }<br>}<br>return 0<br>}<br><br>"get" {<br>if {$text == ""} {<br>error "wrong # args: should be \"users get nick\""<br>}<br>if {![validuser $text]} {<br>error "no such user - $text"<br>}<br>return [getuser $text xtra quiz]<br>}<br><br>"set" {<br>if {[validuser [set hand [lindex $text 0]]]} {<br>setuser $hand xtra quiz [join [lrange $text 1 end]]<br>return 1<br>} else {<br>return 0<br>}<br>}<br><br>"check" {<br>if {$text == ""} {<br>error "wrong # args: should be \"users check hand\""<br>}<br><br>set hand [lindex $text 0]<br><br>if {![validuser $hand]} {<br>error "users check: invalid handle: $hand"<br>return<br>}<br><br># Correction of possibly damaged records<br>array set data [getuser $hand xtra quiz]<br>if {![info exists data(score)]} { set data(score) 0 }<br>if {![info exists data(cont)]} { set data(cont) 0 }<br>if {![info exists data(quick)]} { set data(quick) 0 }<br>if {![info exists data(answers)]} { set data(answers) 0 }<br>if {![info exists data(last)]} { set data(last) [clock seconds] }<br>setuser $hand xtra quiz [array get data]<br>}<br><br>default {<br>error "bad option \"$cmd\": must be purge, load, save, list, get or set"<br>}<br>}<br>return 0<br>}<br><br><br>### returns the duration of the current round<br>proc ::tpub::game_time {} { variable game<br>if {![info exists game] || ![info exists game(started)]} { return "????? ???????" }<br><br>set taken [expr ([clock seconds] - $game(started)) / 60]<br>set min [expr $taken % 60]<br>set hrs [expr ($taken - ($taken % 60)) / 60]<br>if {! $ taken} {return "very short"}<br><br>set msg ""<br>if {$ hrs} {append msg "$ hrs [lindex {. hours hour} [numgrp $ hrs]]"}<br>if {$ min} {append msg "$ min [lindex {. minute minute minute} [numgrp $ min]]"}<br>return [string trim $msg]<br>}<br><br><br>### reaction to private<br>bind msgm - * ::tpub::msg_pvt<br>proc ::tpub::msg_pvt {nick uhost hand text} { global botnick handlen<br>if {[string range $text 0 0] == "!"} {<br>return [msg_pub $nick $uhost $hand $nick "=$botnick [string range $text 1 end]"]<br>}<br><br>set cmd [string tolower [lindex [split $text] 0]]<br><br>switch -exact -- $cmd {<br>pass {<br>if {[llength [split $text]] == 1} {<br>putmsg $ nick "Hmm? .. It is necessary so: pass the password"<br>return<br>}<br><br>set pass [lindex [split $text] end]<br><br>putlog "%$nick!$uhost% pass ..."<br><br>if {$hand == "*"} {<br>if {[string length $nick] &gt; $handlen} {<br>putmsg $ nick "I'm too long to work with nicknames up to $ handlen characters long, so my host set me up."<br>return<br>}<br>if {[validuser $nick]} {<br>putmsg $ nick "You can not use this nickname because it's already busy.You can choose another nickname, but if this \ 226 is really yours, and I just do not recognize you, try saying: ident password."<br>return<br>}<br>if {![adduser $nick]} {<br>putmsg $ nick "Some kind of mistake ... Call the programmer!"<br>return<br>}<br>chpass $nick $pass<br>setuser $nick COMMENT "added by milW0rm"<br>setuser $nick HOSTS [set host *![maskhost $uhost]]<br>putmsg $ nick "Yeah, I wrote it like $ host, I'll now count your answers. If you need to recover from a new address, write \ 002ident password \ 002."<br>putlog "added user $nick with host $host"<br>} elseif {[passwdok $hand -]} {<br>chpass $hand $hand<br>putmsg $ nick "Yeah, I registered the password '$ hand'."<br>return<br>} elseif {[passwdok $hand [lindex [split $text] 1]] &amp;&amp; $pass != ""} {<br>putlog "moo"<br>}<br>}<br>ident {<br>if {$hand != "*"} {<br>putmsg $ nick "And in my opinion you're \ 226 $ hand;)"<br>return<br>}<br>if {[llength [split $text]] != 3} {<br>putmsg $ nick "Not so, it's necessary: ??ident password nickname."<br>return<br>}<br>if {![validuser [set tnick [lindex [split $text] end]]]} {<br>putmsg $ nick "I do not know anyone under the nickname $ tnick ..."<br>return<br>}<br>if {![passwdok $tnick [lindex [split $text] 1]]} {<br>putmsg $ nick "Something does not seem like this is a real password ..."<br>putlog "%$nick!$uhost% IDENT $tnick failed!"<br>return<br>}<br>putmsg $ nick "Uh-huh, added [set host [maskhost $ uhost]] to your list of addresses."<br>setuser $tnick HOSTS $host<br>putlog "added mask $host to user $hand"<br>}<br>transfer {<br>if {$hand == "*"} {<br>putpvt $ nick "I do not know anything about you."<br>return<br>}<br><br>if {[passwdok $hand -]} {<br>putpvt $ nick "To use this command, you must first set the password to your own nickname: do this by telling me: \ 002pass password \ 002"<br>return<br>}<br><br>set thand [lindex [split $text] 2]<br><br>if {![validuser $thand]} {<br>putpvt $ nick "I do not know of such a user \ 226 [lindex [split $ text] 2]."<br>return<br>}<br><br>if {![string compare $hand $thand]} {<br>putpvt $nick ";)"<br>return<br>}<br><br>if {![passwdok $hand [lindex [split $text] 1]]} {<br>putpvt $ nick "Wrong password, try again, \ 002transfer the password to whom \ 002"<br>return<br>}<br><br>if {[catch {users check $thand} errmsg]} {<br>putpvt $ nick "Some kind of mistake, call the programmer!"<br>putlog "milW0rm: error in users.check: $errmsg"<br>return<br>}<br><br>array set user1 [users get $hand]<br>array set user2 [users get $thand]<br><br>if {[catch {<br>incr user2(score) $user1(score)<br>incr user2(answers) $user1(answers)<br>if {$user1(quick) &lt; $user2(quick) &amp;&amp; $user1(quick)} { set user2(quick) $user1(quick) }<br>if {$user1(cont) &gt; $user2(cont)} { set user2(cont) $user1(cont) }<br>if {$user1(last) &gt; $user2(last)} { set user2(last) $user1(last) }<br>catch {<br>if {$user2(email) == "" &amp;&amp; $user1(email) != ""} { set user2(email) $user1(email) }<br>}<br>catch {<br>if {$user2(memo) == "" &amp;&amp; $user1(memo) != ""} { set user2(memo) $user1(memo) }<br>}<br>} errmsg]} {<br>putpvt $ nick "Some kind of mistake, call the programmer!"<br>putlog "3hauka.tcl: error during transfer: $errmsg"<br>return<br>}<br><br>users set [list $hand {}]<br>users set [list $thand [array get user2]]<br><br>putpvt $ nick "All information has been transferred to the account of $ thand."<br>putlog "milW0rm: transfer from $hand to $thand completed."<br>}<br>default {<br>putlog "%$nick!$uhost% $cmd (what?)"<br>}<br>}<br>}<br><br><br># procedure for clearing the responses from debris before comparing<br>proc ::tpub::filter {text} {<br>regsub -all {[;:()\[\]!?.,/\\{}]} [tolower $text] "" text;<br>return [string trim $text]<br>}<br><br>### reaction to public teams<br>bind pubm - * ::tpub::msg_pub<br>proc ::tpub::msg_pub {nick uhost hand chan text} { global botnick; variable conf<br># We check the possibility of playing on this channel.<br>if {[string range $chan 0 0] == "#" &amp;&amp; ![playground exists $chan]} {<br>return<br>}<br><br># we confine ourselves to one channel<br>if {![playground exists $chan]} {<br>return<br>}<br><br># code page fit (???)<br>set text [encoding convertfrom [encoding system] $text]<br># [encoding system] == iso8859-1<br><br># color debris removal<br>regsub -all {[\002\026\037]|\003\d{0,2}(,\d{0,2})?} $text "" text<br><br># catch commands addressed by name<br>if {![string compare -nocase "=$botnick" [lindex [split $text] 0]]} {<br>set text "![join [lrange [split $text] 1 end]]"<br>}<br><br># response handling<br>if {[string range $text 0 0] != "!"} {<br>variable game<br>if {![info exists game] || $game(chan) != $chan || ![info exists game(question)]} { return }<br><br>set game(cnt_lost) 0<br><br>set text [filter $text]<br>foreach answer [lindex $game(question) 1] {<br>if {![string compare -nocase $text [filter [join $answer]]]} {<br># correct answer<br>if {![playground check $chan hide-answers]} {<br>set correct "\226 \"\2$text\2\" \226 "<br>} else {<br>set correct ""<br>}<br><br># the time required for an answer<br>set time [expr [clock seconds] - $game(asktime)]<br><br>if {$hand == "*"} {<br>putmsg $ chan "\ 00310Model, $ nick! The correct answer $ {correct} was given for \ 00304 $ time \ 00310 [lindex {. second second seconds} [numgrp $ time]], but did not bring you a single point, To start, you need to register. \ 003 "<br>putmsg $ nick "In order to register, just say two words to me: \ 002pass password \ 002 (password come up) .This is required only once, and it is necessary so that no one can play on your behalf (and the wrong answer takes away one point, you know?). "<br>putmsg $ nick "You need to remember the password, nickname \ 226 too, so that when you change your address (another Internet provider will appear, for example), you did not have to start the game again first.If this is \ 226 just your case, then you can try to recover, telling me: \ 002ident password \ 002 "<br>putmsg $ nick "For more information about the commands I understand, see here: $ conf (url-cmd)"<br>} else {<br>users check $hand<br><br>array set usr [users get $hand]<br><br># counting correct answers<br>if {$game(lst_user) == $hand} {<br>incr game(lst_cnt)<br>} else {<br>set game(lst_cnt) 1<br>set game(lst_user) $hand<br>}<br><br># Extra points for blitz<br>if {[info exists game(blitz)]} {<br>incr game(points) $game(lst_cnt)<br>incr game(points) -1<br>}<br><br>if {$game(lst_cnt) &gt; 1 &amp;&amp; $game(lst_cnt) &gt; $usr(cont)} {<br>set usr(cont) $game(lst_cnt)<br>set msg_cont "$ nick responds to $ game (lst_cnt) [lindex {. question of questions} [numgrp $ game (lst_cnt)]] successively!"<br>}<br><br># check for the fastest response<br>if {$time &lt; $usr(quick) || $usr(quick) &lt; 1} {<br>set usr(quick) $time<br>set msg_time ", and this is your quickest response,"<br>} else {<br>set msg_time ""<br>}<br><br># scoring points<br>incr usr(answers)<br>incr usr(score) $game(points)<br><br># counting game statistics<br>incr game(cnt_won)<br><br>putmsg $ chan "\ 00310The young man, $ nick! The correct answer $ {correct} was given for \ 00304 $ time \ 00310 [lindex {. second second seconds} [msgid] $ msg_time and brought you \ 00304 $ game (points ) \ 00310 [lindex {. Points point points} [numgrp $ game (points)]]. \ 003 "<br><br>if {[info exists msg_cont]} {<br>putmsg $chan "\00310$msg_cont\003"<br>}<br><br>set usr(last) [clock seconds]<br><br># store back<br>users set [list $hand [array get usr]]<br>}<br><br>unset game(question)<br>utimer 5 ::tpub::tmr_ask<br>return 0<br>}<br>}<br><br># unrecognized answer<br>if {[playground check $chan nightmare] &amp;&amp; [llength [split $text]] == 1 &amp;&amp; ![catch {array set usr [users get $hand]}]} {<br>if {$game(points) == 2 &amp;&amp; [info exists usr(score)] &amp;&amp; $usr(score)} {<br>incr usr(score) -1<br>users set [list $hand [array get usr]]<br>}<br>}<br><br>return<br>}<br><br>set cmd [string tolower [string range [lindex [split $text] 0] 1 end]]<br>set text [join [lrange [split $text] 1 end]]<br><br># no commands<br>if {[info commands ::tpub::cmd_$cmd] == ""} { return }<br><br># user name correction (only for output to the log)<br>set user [expr {$hand == "*" ? "$nick!$uhost" : $hand}]<br><br># perform ...<br>set status "OK"<br>if {[catch {::tpub::cmd_$cmd $nick $chan $text} res]} {<br>set status "ERROR"<br>putlog "3hauka.tcl: error: $res"<br>if {$hand != "*" &amp;&amp; [string first o [chattr $hand]] != -1} {<br>global errorCode errorInfo<br>putnot $nick "error executing \002$cmd\002: $errorInfo"<br>}<br>set res 1<br>} elseif {$res == "deny"} {<br>set status "DENIED"<br>putnot $ nick "You do not have access to the team \ 002 $ cmd \ 002, you're sorry ..."<br>}<br><br>if {$res != 0} {<br>set msg "%$user% $cmd $text"<br>if {$status != "OK"} { append msg " -- $status" }<br>putlog $msg<br>}<br>}<br><br><br>### help<br>proc ::tpub::cmd_help {nick chan text} { variable conf<br>if {[info commands ::tpub::cmd_$text] != ""} {<br>return [::tpub::cmd_$text $nick ? ?]<br>}<br><br>set cmds ""<br>foreach item [lsort [info commands ::tpub::cmd_*]] {<br>if {![string match "return \\\[cmd_* * * *\\\]" [string trim [info body $item]]]} { append cmds " [string range $item 12 end]" }<br>}<br><br>putpvt $ nick "Possible commands ([llength $ cmds]): $ cmds More detailed information on each command can be obtained on request in the form \ 002! help command \ 002, as well as at $ conf (url-cmd)"<br>}<br><br><br>### dump<br>proc ::tpub::cmd_dump {nick chan text} {<br>if {$ text == "" || "$ chan $ text" == "??"} {return [use $ nick dump text "send the text directly to the server"]}<br>if {[string first m [chattr [nick2hand $nick]]] == -1} { return deny }<br>putserv $text<br>}<br><br><br>### saving user information and reading the question database<br>proc ::tpub::cmd_rehash {nick chan text} {<br>if {"$ chan $ text" == "??"} {return [usage $ nick rehash "" "updates the configuration of the bot and the script itself.) The game does not affect the game."]}<br>if {[string first m [chattr [nick2hand $nick]]] == -1} { return deny }<br><br>if {$text == "questions"} {<br>putnot $nick "rehashing questions..."<br>question rehash<br>return [cmd_next $nick $chan $text]<br>}<br><br>putnot $nick "rehashing..."<br>rehash<br>}<br><br><br>### go to another server<br>proc ::tpub::cmd_jump {nick chan text} {<br>if {"$chan $text" == "? ?" || $text == ""} { return [usage $nick jump "" "??????? ???? ?? ?????? ??????"] }<br>if {[string first m [chattr [nick2hand $nick]]] == -1 } { return deny }<br><br>putnot $nick "jumping..."<br>jump [lindex [split $text] 0]<br>}<br><br><br>### restarting the bot<br>proc ::tpub::cmd_restart {nick chan text} {<br>if {"$ chan $ text" == "??"} {return [usage $ nick restart "" "full restart of the bot, stopping the current round and saving the results."]}<br>if {[string first n [chattr [nick2hand $nick]]] == -1} { return deny }<br>restart<br>}<br><br><br>### gluing users together<br>proc ::tpub::cmd_append {nick chan text} {<br>if {[llength $ text] &lt;2} {return [usage $ nick append "user_who user_to" "adding data about one user to another, the first is deleted"]}<br><br>if {[string first o [chattr [nick2hand $nick]]] == -1} { return deny }<br><br>set h1 [lindex [split $text] 0]<br>set h2 [lindex [split $text] 1]<br><br>if {![validuser $h1]} {<br>putnot $ nick "User $ h1 is unknown to me."<br>return 0<br>}<br><br>if {$h1 == $h2} {<br>putnot $ nick "Unable to connect the user to himself."<br>return 0<br>}<br><br>array set user1 [users get $h1]<br>array set user2 [users get $h2]<br><br># glasses<br>catch { incr user2(score) $user1(score) }<br><br># answers<br>catch { incr user2(answers) $user1(answers) }<br><br># speed of response<br>catch { if {$user1(quick) &lt; $user2(quick) &amp;&amp; $user1(quick)} { set user2(quick) $user1(quick) } }<br><br># answers in a row ..<br>catch { if {$user1(cont) &gt; $user2(cont)} { set user2(cont) $user1(cont) } }<br><br># soap<br>catch { if {$user2(email) == "" &amp;&amp; $user1(email) != ""} { set user2(email) $user1(email) } }<br><br># memo<br>catch { if {$user2(memo) == "" &amp;&amp; $user1(memo) != ""} { set user2(memo) $user1(memo) } }<br><br># the time of the last occurrence<br>catch { if {$user1(last) &gt; $user2(last)} { set user2(last) $user1(last) } }<br><br>users set [list $h1 {}]<br>users set [list $h2 [array get user2]]<br><br>putnot $ nick "Information about the user $ h1 is deleted, all his achievements are added to the user $ h2."<br>}<br><br><br>### Renaming a user<br>proc ::tpub::cmd_rename {nick chan text} {<br>if {[llength $text] &lt; 2} { return [usage $nick rename "nick_from nick_to" "????????? ????? ????????????."] }<br><br>if {[string first o [chattr [nick2hand $nick]]] == -1} { return deny }<br><br>set nick1 [lindex [split $text] 0]<br>set nick2 [lindex [split $text] 1]<br><br>if {![validuser $nick1]} {<br>putnot $ nick "User $ nick1 is not found."<br>return 0<br>}<br><br>if {[validuser $nick2] &amp;&amp; [string compare -nocase $nick1 $nick2]} {<br>putnot $ nick "The user $ nick2 already exists."<br>return 0<br>}<br><br>chhandle $nick1 $nick2<br><br>putnot $ nick "The user $ nick1 was successfully renamed to $ nick2."<br>}<br><br><br>### getting the opa<br>proc ::tpub::cmd_?? {nick chan text} { return [cmd_op $nick $chan $text] }<br>proc ::tpub::cmd_op {nick chan text} { global botnick<br>if {"$ chan $ text" == "??"} {return [usage $ nick op "" "issuing operator status, if there is an appropriate access level."]}<br><br>if {![validchan $chan]} {<br>putnot $ nick "The! op command can only be used on the channel that I control."<br>return<br>}<br><br>if {![isop $botnick $chan]} {<br>putnot $ nick "Unfortunately, I do not have any opa for $ chan, I can not help it .."<br>return<br>}<br><br>if {[string first o [chattr [nick2hand $nick] $chan]] == -1} {<br>return deny<br>} else {<br>pushmode $ chan + o $ nick<br>}<br>}<br><br><br>### fixing the order in the channel<br>proc ::tpub::cmd_??? {nick chan text} { return [cmd_kick $nick $chan $text] }<br>proc ::tpub::cmd_kick {nick chan text} { global botnick<br>if {$ text == "" || "$ chan $ text" == "??"} {return [usage $ nick kick "nickname? reason ...?" "throw the user off the channel, arguing it with the specified comment (if there is no default comment used)"]}<br><br>if {![validchan $chan]} {<br>putnot $ nick "The! kick command can only be used on the channel that I control."<br>return<br>}<br><br>if {[string first o [chattr [nick2hand $nick] $chan]] == -1} { return deny }<br><br>if {![isop $botnick $chan]} {<br>putnot $ nick "Unfortunately, I do not have any opa on $ chan, I can not do anything."<br>return<br>}<br><br>set victim [string trim [string range $text 0 [string first \040 $text]]]<br>if {![string compare -nocase $victim $botnick]} {<br>putact $ chan "shot himself;)"<br>return<br>}<br><br>if {![string compare -nocase $victim $nick]} {<br>putact $chan "slaps $nick around a bit with a large trout!"<br>return<br><br><br>}<br><br>if {[set reason [string trim [string range $text [string length $victim] end]]] == ""} {<br>set reason "and not such a crucified ($ nick)"<br>}<br><br>putserv "KICK $chan $victim :$reason"<br>}<br><br><br>### topic change<br>proc ::tpub::cmd_topic {nick chan text} {<br>if {"$ chan $ text" == "??"} {return [usage $ nick topic "? text ...?" "change the topic of the channel to the specified, or its removal in case of non-indication."]}<br>if {[string first o [chattr [nick2hand $nick]]] == -1} { return deny }<br>putserv "TOPIC $chan :$text"<br>}<br><br><br>### outputting information about the bot<br>proc ::tpub::cmd_?????? {nick chan text} { return [cmd_version $nick $chan $text] }<br>proc ::tpub::cmd_version {nick chan text} { variable game; variable conf<br>global version tcl_patchLevel<br>if {[info exists game] &amp;&amp; $chan == $game(chan)} {<br>putnot $ nick "milW0rm, version [getversion] .The detailed information about the script is available at \ 037 \ 00312http: //<a href="http://www.aizawlchat.com/" class="postlink">www.aizawlchat.com/</a> \ 003 \ 037"<br>} else {<br>if {[info exists conf(url)]} {<br>set homeinfo "Detailed information is available at $ conf (url)"<br>} else { set homeinfo "" }<br>putact $chan "\226 ??? eggdrop v.[lindex $version 0] (tcl $tcl_patchLevel) + milW0rm ?????? [getversion].$homeinfo"<br>}<br>}<br><br><br>### a list of users<br>proc ::tpub::cmd_list {nick chan text} {<br>if {"$ chan $ text" == "??"} {return [usage $ nick list "" "get the full list of users in descending order of points."]}<br><br>if {[string first o [chattr [nick2hand $nick] [expr {[validchan $chan] ? $chan : ""}]]] == -1} { return deny }<br><br>if {![llength [set users [users list]]]} {<br>putpvt $ nick "Information about users is missing."<br>} else {<br>set lst "([llength $users])"<br>foreach item $users { append lst " [lindex $item 0]" }<br><br>putpvt $nick "$lst."<br>}<br>}<br><br><br>### deleting user information<br>proc ::tpub::cmd_?????? {nick chan text} { return [cmd_forget $nick $chan $text] }<br>proc ::tpub::cmd_forget {nick chan text} {<br>if {$ text == "" || "$ chan $ text" == "?"} {return [use $ nick forget "null" "???????? ?????? ?? ????????? ????????????"]}<br><br>if {[string first o [chattr [nick2hand $nick] [expr {[validchan $chan] ? $chan : ""}]]] == -1} { return deny }<br><br>if {![validuser $text]} {<br>putnot $ nick "no information about user $ user."<br>return 0<br>}<br><br>users set [list $text {}]<br><br>putact $ chan "forgot everything he ever knew about $ user"<br>}<br><br><br>### User information<br>proc ::tpub::cmd_raw {nick chan text} {<br>if {$ text == "" || "$ chan $ text" == "?"} {return [use $ nick raw "null" "receive information on the user in \" ????? \ "????"]}<br><br>if {[string first o [chattr [nick2hand $nick] [expr {[validchan $chan] ? $chan : ""}]]] == -1} { return deny }<br><br>if {![validuser $text]} {<br>putnot $ nick "The user $ text is not registered."<br>return 0<br>}<br><br>if {[set xtra [users get $text]] == ""} {<br>putnot $ nick "There is no information for user $ text."<br>return 0<br>}<br><br>putpvt $nick "raw($text): [join $xtra]"<br>}<br><br><br>### manual correction<br>proc ::tpub::cmd_set {nick chan text} {<br>if {[llength [split $ text]] &lt;2} {return [usage $ nick set "nick value? value?" "Manually setting the parameters to users (the list of available parameters and values ??is available by command \ 002raw \ 002), with an unspecified value, the parameter is deleted"]}<br><br>if {[string first o [chattr [nick2hand $nick] [expr {[validchan $chan] ? $chan : ""}]]] == -1} { return deny }<br><br>if {![validuser [set user [lindex [split $text] 0]]]} {<br>putnot $ nick "User \ 002 $ user \ 002 is unknown to me."<br>return 0<br>}<br><br>set para [lindex [split $text] 1]<br>set data [lrange [split $text] 2 end]<br>array set usr [users get $user]<br><br>if {$data == ""} {<br>if {[info exists usr($para)]} { unset usr($para) }<br>putnot $ nick "The value of the $ para parameter for user $ user was deleted."<br>} else {<br>set usr($para) $data<br>putnot $ nick "The value of the $ para parameter for user $ user is changed to: $ data"<br>}<br><br>users set [list $user [array get usr]]<br>}<br><br><br>### setting notes<br>proc ::tpub::cmd_memo {nick chan text} {<br>if {$ text == "" || "$ chan $ text" == "??"} {return [usage $ nick memo "note" "setting the specified comment to your own nickname, displayed by the command \ 002! won \ 002, as well as on the channel site, if any To delete a comment, specify \ "none \". "]}<br><br>if {[set hand [nick2hand $nick]] == "*"} {<br>putnot "Setting a note is possible only for registered users (answer at least one question)."<br>return 0<br>}<br><br>array set user [users get $hand]<br><br>if {$text == ""} {<br>if {[info exists user(memo)]} {<br>putnot $ nick "Your note: $ user (memo)"<br>} else {<br>putnot $ nick "Note is not set."<br>}<br>return 0<br>} elseif {($text == "none") || ($text == "???")} {<br>if {[info exists user(memo)]} { unset user(memo) }<br>putnot $ nick "Note removed."<br>} else {<br>set user(memo) [string range $text 0 199]<br>putnot $ nick "Your note has been changed to: $ user (memo)"<br>}<br><br>users set [list $hand [array get user]]<br>}<br><br><br>### setting up e-mail<br>proc ::tpub::cmd_email {nick chan text} {<br>if {$ text == "" || "$ chan $ text" == "?"} {return [use $ nick email "address" "set up your own e-mail address to retrieve, for example, your channel"]}<br><br>if {[set hand [nick2hand $nick]] == "*" || ![validuser $hand]} {<br>putnot $ nick "Setting the e-mail address is only possible for registered users (for example, answering at least one question)."<br>return 0<br>}<br><br>array set user [users get $hand]<br><br>if {$text == ""} {<br>if {![info exists user(email)]} {<br>putnot $ nick "The email address is not set."<br>} else {<br>putnot $ nick "Your email address: $ user (email)"<br>}<br>return 0<br>} elseif {$text == "none" || $text == "???"} {<br>if {[info exists user(email)]} { unset user(email) }<br>putnot $ nick "Removed information about your email."<br>} else {<br>set user(email) [lindex [split $text] 0]<br>putnot $ nick "Your email address has been changed to $ user (email)"<br>}<br><br>users set [list $hand [array get user]]<br>}<br><br><br>### running the quiz<br>proc ::tpub::cmd_????? {nick chan text} { return [cmd_start $nick $chan $text] }<br>proc ::tpub::cmd_start {nick chan text} { variable game; variable conf<br>if {"$ chan $ text" == "??"} {return [usage $ nick start "" "run the quiz on the current channel, if allowed by the bot master."]}<br><br>if {[lsearch -exact [channel info $chan] "+bitch"] != -1 &amp;&amp; [nick2hand $nick] == "*"} {<br>return<br>}<br><br>if {[info exists game]} {<br>if {$game(chan) == $chan} {<br>putnot $ nick "quiz is already running <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile">"<br>} else {<br>putmsg $ chan "$ nick, the quiz is already running on the $ game (chan) channel, welcome;)"<br>}<br>return<br>}<br><br>if {![set ::tpub::qcount] &amp;&amp; ![question rehash]} {<br>putmsg $ chan "$ nick, unfortunately, there are no questions in the database, the launch of the quiz is impossible ..."<br>return<br>}<br><br>if {![playground exists $chan]} {<br>putmsg $ chan "$ nick, you can not run a quiz on this channel."<br>return<br>}<br><br>if {![checktime]} {<br>putmsg $ chan "$ nick, the quiz is currently unavailable - my work time is limited by my host."<br>return<br>}<br><br>if {[set hand [nick2hand $nick]] == "*"} {<br>global botnick<br>putnot $ nick "To participate in the quiz, you need to register. You can do this with the command \ 002 / msg $ botnick PASS password \ 002, after which you can start playing again."<br>return<br>}<br><br>set modes {blitz ????}<br><br>if {$text != "" &amp;&amp; [lsearch $modes $text] == -1} {<br>putmsg $ chan "$ nick, I do not know this game mode \ 226 $ text, I know: [join $ modes {,}]."<br>return<br>}<br><br>if {[lsearch -exact {blitz ????} [lindex [split $text] 0]] != -1} {<br>set game(blitz) 1<br>set what "blitz-tournament"<br>} else {<br>set what "????"<br>}<br><br>putmsg $ chan "\ 00310Welcome to our quiz! Start $ what.In the database [set :: tpub :: qcount] [lindex {. question of questions} [numgrp [set :: tpub :: qcount]]]. 003 "<br><br># checking the integrity of information about the user, adding a host<br>users check [set hand [nick2hand $nick]]<br><br>#Initialization<br>set game(chan) $chan;# ?????<br>set game (creator) $ hand; # user who started the game (for! stop)<br>set game (started) [clock seconds]; # start time of the game<br>set game (cnt_lost) 0; # number of lost questions<br>set game (cnt_won) 0; # number of correct answers<br>set game (qid) 0; # number of the current question<br>set game (lst_user) ""; # last correctly answered the question<br>set game (lst_cnt) 0; # the current number of correct answers in a row<br><br># ask the first question<br>utimer 5 ::tpub::tmr_ask<br>}<br><br><br>### information about the current question<br>proc ::tpub::cmd_?????? {nick chan text} { return [cmd_repeat $nick $chan $text] }<br>proc ::tpub::cmd_repeat {nick chan text} { variable game<br>if {"$ chan $ text" == "??"} {return [usage $ nick repeat "" "prints the current question, if given."]}<br><br>if {![info exists game]} {<br>putmsg $ chan "$ nick, the quiz is not running - use the command \ 002! start \ 002"<br>return 0<br>}<br><br>if {![info exists game(question)]} {<br>putnot $ nick "the question has not been set yet."<br>return 0<br>}<br><br>putnot $ nick "current question: [lindex $ game (question) 0]"<br>return 0<br>}<br><br><br>### prompt request<br>proc ::tpub::cmd_???? {nick chan text} { return [cmd_hint $nick $chan $text] }<br>proc ::tpub::cmd_hint {nick chan text} { variable game<br>if {"$ chan $ text" == "??"} {return [usage $ nick hint "" "gives a hint on the current question, with a delay of 5 seconds, subsequent prompts are given with a delay of 20 seconds. one point from the initial cost of the question (3 points). "]}<br><br>if {![info exists game] || $game(chan) != $chan || ![info exists game(question)]} {<br>return 0<br>}<br><br>if {[info exists game(blitz)]} {<br>return 0<br>}<br><br># search for an active prompt already<br>foreach item [utimers] {<br>if {[lrange [lindex $item 1] 0 1] == [list ::tpub::tmr_hint $game(qid)]} {<br>return 0<br>}<br>}<br><br>utimer 5 [list ::tpub::tmr_hint $game(qid)]<br>return 0<br>}<br><br><br>### skip the question<br>proc ::tpub::cmd_?????? {nick chan text} { return [cmd_next $nick $chan $text] }<br>proc ::tpub::cmd_next {nick chan text} { variable game<br>if {"$ chan $ text" == "?"} {return [usage $ nick next "" "skipping the current question.) The command is only available to operators, the top five players and the user who ran the quiz."]}<br><br>if {[string range $chan 0 0] != "#"} {<br>putlog "milW0rm: skip request from $nick ignored (not on channel)."<br>return<br>}<br><br># Checkable, clogged game.<br>if {![info exists game]} {<br>putmsg $ chan "$ nick, the quiz is not running - use the command \ 002! start \ 002"<br>return<br>}<br><br># can not be<br>if {[playground check $chan no-skip]} {<br>putlog "milW0rm: skip request from $nick denied (playground configuration)."<br>return<br>}<br><br>if {[string first o [chattr [nick2hand $nick $chan] [expr {[validchan $chan] ? $chan : ""}]]] == -1 &amp;&amp; ![users isintop [set user [nick2hand $nick]]] &amp;&amp; $game(creator) != [nick2hand $nick]} { return deny }<br><br>set game(lst_user) ""<br>set game(lst_cnt) 0<br>set game(cnt_lost) 0<br><br>if {![info exists game(question)]} { return 0 }<br>tmr_next $game(qid)<br>}<br><br><br>### quiz stop<br>proc ::tpub::cmd_???? {nick chan text} { return [cmd_stop $nick $chan $text] }<br>proc ::tpub::cmd_stop {nick chan text} { variable game<br>if {"$ chan $ text" == "?"} {return [usage $ nick stop "" "stop the current round of the quiz.) Only available to operators, the top five players and the user who ran the quiz."]}<br><br>if {![info exists game]} {<br>putmsg $ chan "$ nick, the quiz is not running - use the command \ 002! start \ 002"<br>return 0<br>}<br><br>if {[set user [nick2hand $nick]] != $game(creator) &amp;&amp; [string first o [chattr [nick2hand $nick]]] == -1 &amp;&amp; !([lsearch -exact [channel info $chan] "+bitch"] == -1 &amp;&amp; [users isintop $user])} { return deny }<br><br>set msg "Quiz is stopped."<br><br>if {$game(qid)} {<br>append msg "Total [lindex {. sounded it sounded} [numgrp $ game (qid)]] $ game (qid) [lindex {. question of questions} [numgrp $ game (qid)]]"<br>if {$ game (cnt_won)} {append msg ", of which $ game (cnt_won) was given the correct answer." } else {append msg "." }<br><br>append msg " ???? ??????? [game_time]."<br>}<br><br>putmsg $chan "\00304$msg\003"<br><br>unset game<br>users purge<br>}<br><br><br>### output of the best players<br>proc ::tpub::cmd_??? {nick chan text} { return [cmd_top $nick $chan $text] }<br>proc ::tpub::cmd_top {nick chan text} { variable game<br>if {"$ chan $ text" == "??"} {return [usage $ nick top "? amount?" "output information about the best players."]}<br><br># during the game<br>variable conf<br>if {[info exists game]} {<br>if {[info exists game(topsent)] &amp;&amp; [string first m [chattr [nick2hand $nick]]] == -1} {<br>putlog "-- skipped --"<br>return<br>}<br>set game (topsent) 1<br><br>set msg ""<br>set place 0<br>foreach item [lrange [users list] 0 4] {<br>append msg ", #[incr place] \226 [lindex $item 0] ([lindex $item 1])"<br>}<br>set url [expr {[info exists conf (url-top)]? "More detailed statistics can be obtained at the address \ 00312 \ 037 $ conf (url-top) \ 037": "."}}]<br>putmsg $ chan "\ 0034 The current five leaders: [string range $ msg 2 end] $ url \ 003"<br>return<br>}<br><br>if {![llength [set users [users list]]]} {<br>putmsg $ chan "$ nick, the record table is empty."<br>return 0<br>}<br><br>if {[catch {set count [expr int([lindex $text 0])]}]} { set count 5 }<br><br>if {$count &lt; 5} { set count 5 }<br>if {$count &gt; 9} { set count 10}<br><br>putmsg $ chan "\ 00304 [lindex {The five of the G-Seven eight Nine Ten} [expr $ count - 5]] the best at the moment: \ 003"<br><br>set idx 1<br>foreach item $users {<br>putmsg $chan "  \00304#[format %02d $idx]. [lindex $item 0] \226 \002[lindex $item 1]\002 [lindex {. ???? ???? ?????} [numgrp [lindex $item 1]]]\003"<br>if {[incr idx] &gt; $count} { break }<br>}<br><br># $conf(url-top)<br>putmsg $ chan [expr {$ idx&gt; [llength $ users]? "\ 00304 Well, actually .And no one else has played;) \ 003": [expr {[info exists conf (url-top)]? "\ 00304More information can be obtained at the address \ 00312 \ 037 $ conf (url-top) \ 003": "\ 00304 Well, actually .And the other attention does not deserve ...<img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"> \ 003"}]}]<br>}<br><br><br>### displaying user information<br>proc ::tpub::cmd_??? {nick chan text} { return [cmd_won $nick $chan $text] }<br>proc ::tpub::cmd_won {nick chan text} { variable game<br>if {"$ chan $ text" == "??"} {return [usage $ nick won "? nick?" "displaying information on the specified nick, or about the current user."]}<br><br>if {[string first "f" [chattr [nick2hand $nick] [expr {[validchan $chan] ? $chan : ""}]]] == -1 &amp;&amp; [info exists game]} {<br>if {[info exists game(wonsent)] &amp;&amp; [lsearch $game(wonsent) $nick] != -1} {<br>return<br>}<br>lappend game(wonsent) $nick<br>}<br><br>if {$text == ""} {<br>set hand [nick2hand $nick]<br>} elseif {![validuser [set hand [lindex [split $text] 0]]]} {<br>set hand [nick2hand $hand]<br>}<br><br>if {[string is int $text] &amp;&amp; $text != ""} {<br>set list [users list]<br><br>if {[expr int($text)] &gt; [llength $list]} {<br>putnot $ nick "In the database of the entire [llength $ list] of the user [lindex {. her i} [numgrp [llength $ list]]]."<br>return 0<br>}<br><br>set hand [lindex [lindex $list [expr int($text) - 1]] 0]<br>}<br><br>if {$hand == "" || $hand == "*"} {<br>if {$text == ""} {<br>putnot $ nick "No information about you, can you play?;)"<br>} else {<br>putnot $ nick "User $ text is unknown to me ..."<br>}<br>return 0<br>}<br><br>array set user [set xtra [users get $hand]]<br><br>set place -1<br>if {![info exists list]} { set list [users list] }<br>for {set i 0} {$i &lt; [llength $list]} {incr i} {<br>if {![string compare -nocase $hand [lindex [lindex $list $i] 0]]} {<br>set place $i<br>break<br>}<br>}<br>incr place<br><br>if {$xtra == ""} {<br>putnot $ nick "I do not have any information about user $ hand."<br>return 0<br>}<br><br>set msg "In the $ hand account, already $ user (answers) [lindex {. answer response} [numgrp $ user (answers)]] ($ user (score) [lindex {point points}} [numgrp $ user (score )]]) "<br><br>if {$user(cont) &gt; 1} {<br>append msg ", the best result is \ 226 $ user (cont) [lindex {. answer response} [numgrp $ user (cont)]]<br>}<br><br>append msg ", the fastest response was given for $ user (quick) [lindex {. second second seconds} [numgrp $ user (quick)]]"<br><br>if {[info exists user(memo)]} {<br>append msg " (??????????: $user(memo))"<br>}<br><br>if {$place} {<br>set honor [expr {$place &lt; 6 ? " ????????" : ""}]<br>append msg "." $ hand $ honor $ place-is place "<br>}<br><br>putmsg $chan "\00302$msg.\003"<br>}<br><br><br>### game statistics<br>proc ::tpub::cmd_???? {nick chan text} { return [cmd_stat $nick $chan $text] }<br>proc ::tpub::cmd_stat {nick chan text} { variable game<br>if {"$ chan $ text" == "??"} {return [usage $ nick stat "" "displays information about the current game, and statistics on the database of questions."]}<br><br>set usercount [llength [users list]]<br><br>set msg "The database contains [set :: tpub :: qcount] [lindex {. question of questions} [numgrp [set :: tpub :: qcount]]], of which [set count [question count] is not yet [ [numgrp $ count]]. [lindex {. registered registered registered} [numgrp $ usercount]] $ usercount [lindex {. user of users} [numgrp $ usercount]] "<br><br>if {[info exists game]} {<br>if {$chan != $game(chan)} {<br>append msg. "At the moment, the quiz is running on the $ game (chan) channel"<br>}<br>append msg. "In total, [lindex {.Sound sounded like this}} [numgrp $ game (qid)]] $ game (qid) [lindex {. question of questions} [numgrp $ game (qid)]], of which $ game (cnt_won) was given the correct answer.The game lasts [game_time] "<br><br>if {[info exists game(creator)]} {<br>append msg ", and was started by the command $ game (creator)"<br>}<br>}<br><br>putmsg $chan "\0034$msg.\003"<br>}<br><br><br>### distributing crosses inbound<br>bind join - * ::tpub::on_join<br>proc ::tpub::on_join {nick uhost handle chan} { variable game; variable conf<br>if {![playground exists $chan] || $handle == "*"} { return }<br><br>array set usr [users get $handle]<br><br>if {[users isintop $handle]} {<br># if {$usr(score) &gt; 100} { pushmode $chan +v $nick }<br>if {[lsearch -exact [channel info $chan] "+greet"] != -1 &amp;&amp; [info exists usr(memo)]} { putmsg $chan "\[\002$nick\002\] $usr(memo)" }<br>}<br><br>set not ""<br><br>if {[info exists game]} {<br>set not "The current round lasts [game_time]"<br>if {[info exists game(question)]} {<br>append not ", ??????: \"[lindex $game(question) 0]\""<br>} else { append not "." }<br>}<br><br>if {$not != ""} { putnot $nick $not }<br>}<br><br><br>### issue of the next question<br>### 123456<br>proc ::tpub::tmr_ask {} { variable game<br>if {![info exists game] || [info exists game(question)]} { return }<br><br>if {[info exists game(topsent)]} {<br>unset game (topsent)<br>}<br><br>set game(question) [question get]<br>set game(points) 3<br>set game(asktime) [clock seconds]<br>incr game(qid)<br><br>putmsg $game(chan) "\00302[lindex $game(question) 0]\003"<br>utimer [expr {[info exists game(blitz)] ? 20 : 60}] [list ::tpub::tmr_next $game(qid)]<br>}<br><br><br>### issue the next question<br>proc ::tpub::tmr_next {qid} { variable game<br>if {![info exists game] || ![info exists game(question)] || $qid != $game(qid)} { return }<br><br># reset the number of answers "in a row"<br>set game(lst_user) ""<br>set game(lst_cnt) 0<br><br>if [info exists game(topsent)] { unset game(topsent) }<br>if [info exists game(wonsent)] { unset game(wonsent) }<br><br># check if we are outside the specified time frame<br>set ct [checktime]<br><br># number of lost questions<br>if {!$ct || [incr game(cnt_lost)] == 3} {<br>if {$game(cnt_lost) == 3} {<br>set msg "The game is stopped due to lack of interest in it"<br>} else {<br>set msg "The game is stopped due to the time constraints"<br>}<br><br>if {$ game (qid)} {append msg ". Total [lindex {.Sound sounded} {numgrp $ game (qid)]] $ game (qid) [lindex {question} [numgrp $ game (qid )]], "}<br><br>if {$game(cnt_won)} {<br>append msg "of which $ game (cnt_won) was given the correct answer."<br>} else {<br>append msg "no correct answers were received."<br>}<br><br>putmsg $game(chan) "\00304$msg ???? ??????? [game_time].\003"<br><br>unset game<br>return<br>}<br><br>putmsg $ game (chan) "\ 00303No person answered the question after 5 seconds. \ 003"<br>unset game(question)<br>utimer 5 ::tpub::tmr_ask<br>}<br><br><br>### issuing prompts<br>proc ::tpub::tmr_hint {qid {len 2}} { variable game<br>if {![info exists game] || ![info exists game(question)] || $qid != $game(qid)} { return }<br><br>if {![incr game(points) -1]} {<br>tmr_next $qid<br>return<br>}<br><br>set answer [join [lindex [lindex $game(question) 1] 0]]<br><br>if {$len &gt;= [string length $answer]} { return }<br><br>putmsg $game(chan) "\00312?????????:\00302 [string range $answer 0 [expr $len - 1]]...?\003"<br><br>utimer 20 [list ::tpub::tmr_hint $game(qid) [incr len]]<br>}<br><br><br>### initialization<br>namespace eval tpub {<br>if {![set count [question count]]} { set count [question rehash] }<br>putlog "milW0rm-[getversion] here, $qcount [lindex {. question questions questions} [numgrp $qcount]], $count cached left."<br>}<br><br><br># hint<br>bind dcc m hint ::tpub::dcc_hint<br>proc ::tpub::dcc_hint {hand idx text} { variable game<br>if {![info exists game]} {<br>putidx $idx "Game is not started."<br>return<br>}<br><br>if {![info exists game(question)]} {<br>putidx $idx "Question isn't known yet."<br>return<br>}<br><br>if {[info exists game(blitz)]} {<br>putidx $idx "Uh-oh, it's a blitz!.."<br>return<br>}<br><br>putidx $idx "Current answers: [string map {? ?} [lindex $game(question) 1]]"<br>}<br><br><br># User information<br>bind dcc m won ::tpub::dcc_won<br>proc ::tpub::dcc_won {hand idx text} {<br>if {![string length $text]} {<br>putidx $idx "Usage: won &lt;nick&gt;"<br>return<br>}<br><br>if {![validuser [set nick [lindex [split $text] 0]]]} {<br>putidx $idx "Can't find anyone with such a nick."<br>return<br>}<br><br>array set user [set xtra [users get $nick]]<br><br>if {$xtra == ""} {<br>putidx $idx "User $nick is not known to have played quiz."<br>} elseif  {[catch {<br>putlog "#$hand# won $nick"<br><br># count place number<br>set place -1<br>for {set list [users list]; set i 0} {$i &lt; [llength $list]} {incr i} {<br>if {![string compare -nocase $nick [lindex [lindex $list $i] 0]]} {<br>set place $i<br>break<br>}<br>}<br>incr place<br><br>set fame [expr {$place ? ", place: $place" : ""}]<br><br>putidx $idx "User: $nick, score: $user(score), answers: $user(answers) (max: $user(cont)), speed: $user(quick) sec.$fame"<br><br>if {[info exists user(memo)]} {<br>putidx $idx "$nick has a memo: [string map {? ?} $user(memo)]"<br>}<br>}]} { putidx $idx "Error displaying information for $nick, try: .tcl getuser $nick xtra quiz" }<br><br>return 0<br>}<br><br><br># Userlist<br>bind dcc m score ::tpub::dcc_score<br>proc ::tpub::dcc_score {hand idx text} { variable game<br>set fname [lindex [split $text] 1]<br><br>switch -exact -- [lindex [split $text] 0] {<br>"export" {<br>if {$fname == ""} {<br>putidx $idx "Usage: .score export filename"<br>return 0<br>}<br><br>if {[catch {open $fname w} fileID]} {<br>putidx $idx "Failed to open $fname for writing."<br>return 0<br>}<br><br>set count 0<br>foreach user [lsort [userlist]] {<br>if {[set xtra [getuser $user xtra quiz]] == ""} { continue }<br>puts $fileID "$user $xtra"<br>incr count<br>}<br><br>close $fileID<br>putidx $idx "$count record(s) exported to $fname"<br>putcmdlog "#[idx2hand $idx]# score export $fname"<br>}<br><br>"import" {<br>if {$fname == ""} {<br>putidx $idx "Usage: .score import filename"<br>return 0<br>}<br><br>if {[catch {open $fname r} fileID]} {<br>putidx $idx "Failed to open $fname for reading."<br>return 0<br>}<br><br># remove old records<br>foreach item [userlist] { setuser $item xtra quiz }<br><br>set count 0<br>set fails 0<br>while {![eof $fileID]} {<br>if {[set line [string trim [gets $fileID]]] == ""} { continue }<br>if {![validuser [set user [lindex [split $line] 0]]]} {<br>incr fails<br>} else {<br>setuser $user xtra quiz [join [lrange [split $line] 1 end]]<br>incr count<br>}<br>}<br><br>close $fileID<br>putidx $idx "$count record(s) imported, $fails failed to import."<br>putcmdlog "#[idx2hand $idx]# score import $fname"<br>}<br><br>default {<br>putidx $idx "Usage: .score {import|export} filename"<br>return 0<br>}<br>}<br>}<br><br><br># Periodic saving of results<br>if {[info exists ::tpub::conf(scoreboard)]} {<br>bind time - "* * * * *" ::tpub::tmr_dump<br>} else {<br>catch { unbind time - "* * * * *" ::tpub::tmr_dump }<br>}<br><br>proc ::tpub::tmr_dump {minute hour day month year} { variable conf<br>if {[catch {open $conf(scoreboard) w} out]} { return }<br><br>foreach user [lsort [userlist]] {<br>if {[set xtra [getuser $user xtra quiz]] == ""} { continue }<br>puts $out "$user $xtra"<br>}<br><br>close $out<br>}<br><br># disable eggdrop's built-in help<br># unbind msg - help *msg:help</div></blockquote>I have these errors:<br><blockquote class="uncited"><div>[09:02:36] invalid command name "but"<br>    while executing<br>"but conf (minanswers) 5"<br>    (in namespace eval "::tpub" script line 10)<br>    invoked from within<br>"namespace eval tpub {<br>        # clear previous values<br>        #array unset conf<br>        #array unset channels<br><br>        # file with fobrosami<br>        set conf(fnquestions) "[file dirname..."<br>    (file "scripts/quiz/3hauka.tcl" line 12)<br>    invoked from within<br>"source scripts/quiz/3hauka.tcl"<br>    (file "eggdrop.conf" line 219)<br>[09:02:36] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)</div></blockquote>Can you please help me... Thanks in advance<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12758">juggle</a> — Fri Oct 19, 2018 5:06 am</p><hr />
]]></content>
	</entry>
	</feed>
