Advertisement
IRCgo

Untitled

Feb 23rd, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.36 KB | None | 0 0
  1. ################## Written by Murf 10/10/97 ##################
  2. ## ##
  3. ## Requires wordlist.txt and wscore file ##
  4. ## I have included a wordlist file, but if you want to write ##
  5. ## your own, the format is ##
  6. ## <word to scramble>:<clue> ##
  7. ## ##
  8. ## ##
  9. ## ##
  10. ## The only commands are: ##
  11. ## ##
  12. ## !word -- starts the game ##
  13. ## !score -- spews the top ten scorers ##
  14. ## !wordswitch -- turns it on or off ##
  15. ## !wordanswer -- turn the answer on or off ##
  16. ###############################################################
  17.  
  18. ## NOTES
  19.  
  20. # Scores are kept globally
  21. # Scores are only kept for those in the bot's user list.
  22. # The special user used to track various things, is added
  23. # by the script.
  24.  
  25. ## REVISION HISTORY
  26.  
  27. # July 9 2000 -- Added switch to say/not say the answer if no one gets it.
  28. # -- Got rid of all the 'putchan's
  29. # July 2 2000 -- Fixed bug in the_score that didn't account for
  30. # less than 10 people in the score list.
  31. # -- Fixed bug in the_score that failed to check for
  32. # non-existent score file.
  33.  
  34. ## BINDS
  35.  
  36. #Change the f|f if you want.
  37.  
  38. bind pub - !score the_score
  39. bind pub - !word pub_word
  40. bind time - "05 03 % % %" wo_refresh_time
  41. bind msg m !wordswitch word_onoff
  42. bind msg m !answer answer_onoff
  43.  
  44. ## VARIABLES, set these.
  45.  
  46. # This is the file that holds the wordlist, set it to whatever
  47. set wlistfile /home/sonny/eggdrop/scripts/added/wordgame/wordlist.txt
  48.  
  49. # This file keeps scores again call it whatever
  50. set wscorefile /home/sonny/eggdrop/scripts/added/wscore
  51.  
  52. # This special user is added to the bots userlist and used to track
  53. # where each chan is in the wordlist
  54. set specuser specialwd
  55.  
  56. # Say the answer if no one gets it
  57. # 0 is don't say it / 1 is say it
  58. set ansonoff 0
  59.  
  60. ## ----------------Leave the rest alone----------------------------------
  61.  
  62. # This variable tells whether the script is being run. It will only allow
  63. # the game to be played in one channel at a time, otherwise too many timers
  64. # too much confusion.
  65. # Occasionally, the script may become confused during desynchs and says its
  66. # running when it isn't. You must reset this variable to 0. Don't worry
  67. # it doesnt happen often. Obviously leave it set to 0 here
  68. set winuse 0
  69.  
  70. # This variable is the place in the wordlist. Its initialized to 0 don't
  71. # mess with it. I tried randomizing this, but found this worked better,
  72. # but its not hard to randomize if you like that better.
  73. set word_list_count 0
  74.  
  75. # On off switch for the annoying people
  76. # 0 is off/ 1 is on
  77. set glonoff 1
  78.  
  79. # Global channel variable, initialized to null, leave alone
  80. set chan ""
  81.  
  82. # Initializes global wordlist to null, leave it alone
  83. set words ""
  84.  
  85. # ----------CODE--------------------------------------------------------
  86.  
  87. # Procedure to turn on/off whether the answer is given if no one
  88. # gets it.
  89. proc answer_onoff {nick uhost handle args} {
  90. global ansonoff botnick
  91. set onoff [string tolower [ string trim [lindex [split $args] 0] "{}" ]]
  92. if {$onoff == "on"} {
  93. set ansonoff 1
  94. putserv "NOTICE $nick :Wordgame will now tell you losers the answers ;-P"
  95. return
  96. }
  97. if {$onoff == "off"} {
  98. set ansonoff 0
  99. putserv "NOTICE $nick :Wordgame will no longer tell you losers the answers"
  100. return
  101. }
  102. putserv "NOTICE $nick :USAGE: /msg $botnick !wordanswer on\/off"
  103. return
  104. }
  105.  
  106. # Had to add an on off switch cause some pple started annoying me
  107. proc word_onoff {nick uhost handle args} {
  108. global botnick glonoff
  109. set onoff [string tolower [ string trim [lindex [split $args] 0] "{}" ]]
  110. if {$onoff == "on"} {
  111. set glonoff 1
  112. putserv "NOTICE $nick :Wordgame is turned on"
  113. return
  114. }
  115. if {$onoff == "off"} {
  116. set glonoff 0
  117. putserv "NOTICE $nick :Wordgame is turned off"
  118. return
  119. }
  120. putserv "NOTICE $nick :USAGE: /msg $botnick !wordswitch on\/off"
  121. return
  122. }
  123.  
  124. # This is the main proc, it spews the word and sets the timers to do the
  125. # rest.
  126.  
  127. proc pub_word {nick uhost handle channel args} {
  128. global wscorefile wlistfile words word_list_count answer winuse \
  129. chan letone lettwo letters specuser glonoff
  130. if {$glonoff == 0} {
  131. putserv "PRIVMSG $channel :Sorry, wordgame is turned off, try again later"
  132. return
  133. }
  134. set chn [string tolower $channel]
  135. if {$word_list_count == 0} {
  136. if {![validuser $specuser]} {
  137. set channels [channels]
  138. adduser $specuser [email protected]
  139. foreach chann $channels {
  140. setuser $specuser XTRA wcount.$chann 0
  141. }
  142. }
  143. set word_list_count [getuser $specuser XTRA wcount.$chn]
  144. set words ""
  145. set fd [open $wlistfile r]
  146. while {![eof $fd]} {
  147. lappend words [gets $fd]
  148. }
  149. close $fd
  150. }
  151. if {($winuse == 1) && ([string compare $chn $chan] != 0)} {
  152. putserv "PRIVMSG $chn :Sorry, they're already playing in $chan, go join in. I'll tell em your coming, $nick."
  153. return 0
  154. } elseif {($winuse == 1) && ([string compare $chn $chan] == 0)} {
  155. putserv "PRIVMSG $chan :HEY! One word at a time!"
  156. return 0
  157. } elseif {$winuse == 0} {
  158. set chan $chn
  159. set winuse 1
  160. set word_pair [lindex $words $word_list_count]
  161. set answer [lindex [split $word_pair :] 1]
  162. set word_split [split $word_pair :]
  163. set letters [lreplace $word_split 1 1]
  164. set let_split [split $letters {}]
  165. set letone [lindex $let_split 0]
  166. set slettwo $letone
  167. set slettwo [join [lappend slettwo [lindex $let_split 1]]]
  168. regsub { } $slettwo {} lettwo
  169. set i [llength $let_split]
  170. set smixed ""
  171. set tmixed ""
  172. for {set j 0} {$j < $i} {incr j} {
  173. set k [rand [llength $let_split]]
  174. set smixed $tmixed
  175. set smixed [lappend smixed [lindex $let_split $k]]
  176. set let_split [lreplace $let_split $k $k]
  177. regsub { } $smixed {} tmixed
  178. }
  179. set mixed $tmixed
  180. bind pub - $letters pub_gotit
  181. putserv "PRIVMSG $chan :Unscramble ---> \0036 $mixed "
  182. incr word_list_count
  183. if {$word_list_count >= [expr [llength $words] -1]} {
  184. set word_list_count "0"
  185. }
  186. setuser $specuser XTRA wcount.$chn $word_list_count
  187. utimer 60 noone_gotit
  188. utimer 15 clue_1
  189. utimer 30 clue_2
  190. utimer 45 clue_3
  191. }
  192. }
  193.  
  194. # All the timers expired and no one got it. Spew to chan.
  195.  
  196. proc noone_gotit {} {
  197. global winuse chan letters ansonoff
  198. if {$ansonoff} {
  199. putserv "PRIVMSG $chan :Nobody got it...it\'s \0034$letters"
  200. } else {
  201. putserv "PRIVMSG $chan :Nobody got it...\0034losers!"
  202. }
  203. unbind pub - $letters pub_gotit
  204. set winuse 0
  205. set chan ""
  206. }
  207.  
  208. # List of things to say when a validuser wins
  209.  
  210. set winsay {
  211. "must be a fluke"
  212. "you rule!!"
  213. "how's that VD comin along?"
  214. "can I be your friend?"
  215. "you're such a badass!"
  216. "must have gotten all the easy ones!"
  217. "but you still suck!"
  218. "you must be on \0034fire!!"
  219. "cheater!"
  220. }
  221.  
  222. # Somebody won, spew to chan and update score file. Scores are kept for both
  223. # daily and cumulative. Once anyone hits 500 all scores are reset.
  224.  
  225. proc pub_gotit {nick uhost handle channel args} {
  226. global wscorefile words letters answer winuse chan winsay
  227. putserv "PRIVMSG $chan :Woohoo $nick!! You got it...\0034$letters"
  228. kill_timers
  229. unbind pub - $letters pub_gotit
  230. if {![validuser $handle]} {
  231. set winuse 0
  232. set chan ""
  233. return 0
  234. }
  235. if {![file exists $wscorefile]} {
  236. set fd [open $wscorefile w]
  237. close $fd
  238. }
  239. set fd [open $wscorefile r]
  240. set j 0
  241. while {![eof $fd]} {
  242. lappend score [gets $fd]
  243. set j [incr j]
  244. }
  245. set i [expr $j - 1]
  246. set score [lreplace $score $i $i]
  247. close $fd
  248. for {set k 0} {$k < $i} {incr k 3} {
  249. set scnick [lindex $score $k]
  250. if {$handle == $scnick} {
  251. set newd [expr [lindex $score [expr $k + 1]] + 1]
  252. set newf [expr [lindex $score [expr $k + 2]] + 1]
  253. set score [lreplace $score [expr $k + 1] [expr $k + 2] $newd $newf]
  254. set dscore [lindex $score [expr $k + 1]]
  255. set rand_say [lindex $winsay [rand [llength $winsay]]]
  256. putserv "PRIVMSG $chan :$nick you've won $dscore times today, $rand_say"
  257. if {$newf == 500} {
  258. putserv "PRIVMSG $chan :OH MY GAWD!! $scnick just scored 500 since time began!"
  259. set score [lreplace $score 1 2 0 0]
  260. for {set k 1} {$k < $i} {incr k 2} {
  261. set score [lreplace $score $k $k 0]
  262. incr k
  263. set score [lreplace $score $k $k 0]
  264. }
  265. putserv "PRIVMSG $chan :\001ACTION sprinkles bot dust and time begins again!"
  266. }
  267. set winuse 0
  268. set chan ""
  269. set fd [open $wscorefile w]
  270. foreach line $score {
  271. puts $fd $line
  272. }
  273. close $fd
  274. return 0
  275. }
  276. }
  277. putserv "PRIVMSG $chan :$nick this is your first ever win!!!...Don't you feel pathetic!"
  278. set score [lappend score $handle]
  279. set score [lappend score 1]
  280. set score [lappend score 1]
  281. set fd [open $wscorefile w]
  282. foreach line $score {
  283. puts $fd $line
  284. }
  285. close $fd
  286. set winuse 0
  287. set chan ""
  288. }
  289.  
  290. proc the_score {nick uhost handle channel args} {
  291. global botnick wscorefile words answer winuse chan
  292. if {($winuse == 1) && ($chan == $channel)} {
  293. putserv "PRIVMSG $chan :Sheesh! Can't you see we're playing here!!"
  294. return 0
  295. }
  296. if {![file exists $wscorefile]} {
  297. putserv "PRIVMSG $chan : No one has scored yet!"
  298. return
  299. }
  300. set fd [open $wscorefile r]
  301. set j 0
  302. while {![eof $fd]} {
  303. lappend score [gets $fd]
  304. incr j
  305. }
  306. set i [expr $j - 1]
  307. set score [lreplace $score $i $i]
  308. close $fd
  309. set looptest [llength $score]
  310. if {$looptest > 30} {
  311. set looptest 30
  312. }
  313. for {set k 0} {$k < $looptest} {incr k 3} {
  314. set wosnick [lindex $score $k]
  315. set dscore [lindex $score [expr $k + 1]]
  316. set fscore [format "%d" [lindex $score [expr $k + 2]]]
  317. lappend tempsortscore [format "%.20d %d %s" $fscore $dscore $wosnick]
  318. }
  319. set tempsortscore [lsort -decreasing $tempsortscore]
  320. set k 0
  321. foreach i $tempsortscore {
  322. incr k
  323. set newtempsortscore [string trimleft [lindex $i 0] 0]
  324. append sortscore [format "\0034 %s\.\003 %s\(%d\/%d\) " $k [lindex $i 2] $newtempsortscore [lindex $i 1]]
  325. }
  326. set slength [llength $sortscore]
  327. putserv "PRIVMSG $channel :The top 10 Scramble scorers are (Total/Daily):"
  328. putserv "PRIVMSG $channel :$sortscore"
  329. }
  330.  
  331. # Give clue word
  332.  
  333. proc clue_1 {} {
  334. global chan answer
  335. set clue $answer
  336. putserv "PRIVMSG $chan :Clue --->\00312 $clue"
  337. }
  338.  
  339.  
  340. # Give first letter of the word
  341.  
  342. proc clue_2 {} {
  343. global chan letone
  344. set clue $letone
  345. putserv "PRIVMSG $chan :First letter --->\00312 $clue"
  346. }
  347.  
  348. # Give the second letter
  349.  
  350. proc clue_3 {} {
  351. global chan lettwo
  352. set clue $lettwo
  353. putserv "PRIVMSG $chan :First two letters --->\00312 $clue"
  354. }
  355.  
  356. # Kill all remaining timers when someone wins.
  357.  
  358. proc kill_timers {} {
  359. global chan
  360. foreach j [utimers] {
  361. if {[lindex $j 1] == "noone_gotit"} {
  362. killutimer [lindex $j 2]
  363. }
  364. if {[lindex $j 1] == "clue_1"} {
  365. killutimer [lindex $j 2]
  366. }
  367. if {[lindex $j 1] == "clue_2"} {
  368. killutimer [lindex $j 2]
  369. }
  370. if {[lindex $j 1] == "clue_3"} {
  371. killutimer [lindex $j 2]
  372. }
  373. }
  374. return 0
  375. }
  376.  
  377. # Its 3:00 am, clear the daily scores.
  378.  
  379. proc wo_refresh_time {m h d mo y} {
  380. global wscorefile
  381. set fd [open $wscorefile r]
  382. set j 0
  383. while {![eof $fd]} {
  384. lappend score [gets $fd]
  385. set j [incr j]
  386. }
  387. set i [expr $j - 1]
  388. set score [lreplace $score $i $i]
  389. close $fd
  390. set score [lreplace $score 1 1 0]
  391. for {set k 1} {$k < $i} {incr k 3} {
  392. set score [lreplace $score $k $k 0]
  393. }
  394. set fd [open $wscorefile w]
  395. foreach line $score {
  396. puts $fd $line
  397. }
  398. close $fd
  399. return 1
  400. }
  401.  
  402. putlog "Wordgame by murf loaded"
  403.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement