All pastes #766115 Raw Edit

xmas

public text v1 · immutable
·published 2007-11-08 17:00 UTC
rendered paste body
##############################
# script: story.tcl          #
# author: Dany Gagnon (husk) #
##############################
# NOTE : this isn't a tcl made exclusively for #christmas

bind pub - !story training:do
bind pub - !stop training:stop
bind part - * training:part
bind nick - * training:nick
proc training:do {nick host hand chan arg} { training $chan $arg $nick $host }
proc training:stop {nick host hand chan arg} { global training; set training(status) "off"; puthelp "MODE $training(chan) -m"; puthelp "TOPIC $training(chan) :Welcome to $training(chan), home of Undernet's Christmas spirit. To view the Christmas Story type !story. Can translate? => daydreamr@gmail.com [WeBCaT]" ; if {$training(nick) != "doNOTdevoice"} { pushmode $training(chan) -v $training(nick) } }
proc training:part {nick host hand chan arg} { global training; if {$training(host) == $host && $training(status) == "on"} { puthelp "MODE $training(chan) -m"; puthelp "TOPIC $chan :Welcome to $training(chan), home of Undernet's Christmas spirit. To view the Christmas Story type !story. Can translate? => daydreamr@gmail.com [WeBCaT]"; set training(status) "off"; if {$training(nick) != "doNOTdevoice"} { pushmode $training(chan) -v $training(nick) } } }
proc training:nick {nick host hand chan nnick} { global training; if {$training(nick) == $nick} { set training(nick) $nnick } }
###############################
set training(chan) "#christmas";
set training(fline) "";
set training(eline) "";
set training(file) "";
set training(status) "off";
set training(ammount) "10";
set training(line) "0";
set training(host) "";
set training(nick) "";
###############################

proc ttest {} {
global training;
if {$training(status) == "off"} { return; }
 
    set fp [open $training(file) r]
     fconfigure $fp -buffering line
     gets $fp data
     set line 0;
     set x $training(fline); incr x;
     while {$data != ""} {
     if {$line == $training(fline)} { set training(ammount) "[expr [string length $data] / 10]"; putserv "privmsg $training(chan) :$data"; };
      incr line;
      gets $fp data;
      }
     flush stdout; close $fp
     global training(line); incr training(line);
     if {$x > $training(eline)} { putserv "privmsg $training(chan) :End of the story" ; puthelp "MODE $training(chan) -m"; puthelp "topic $training(chan) :Welcome to $training(chan), home of Undernet's Christmas spirit. To view the Christmas Story type !story. Can translate? => daydreamr@gmail.com [WeBCaT]" ; set training(status) "off"; if {$training(nick) != "doNOTdevoice"} { pushmode $training(chan) -v $training(nick) } ; return; }
     global training(fline); set training(fline) $x;
     set timertraining [utimer $training(ammount) ttest];
}

proc training { chan part nick uhost } {
global training;
if {$training(status) == "on"} { return }
if {$part == ""} { set part "english"; }

if {![file exists "/usr/home/assign/eggdrop/story/$part.txt"]} { putserv "privmsg $chan :* Error - invalid language or option specified!"; return }
     puthelp "TOPIC $chan :You're reading the $part Christmas story brought to you by Undernet. Enjoy some Christmas spirit with us! :)";
set training(host) $uhost;
set training(nick) $nick;
if {[isvoice $nick $chan] != "0"} { set training(nick) "doNOTdevoice" }
   if {$training(nick) != "doNOTdevoice"} { pushmode $chan +v $nick; }
     puthelp "MODE $chan +m"
     set training(file) "/usr/home/assign/eggdrop/story/$part.txt";
     set training(fline) 0;
     set training(chan) $chan;

     set fp [open $training(file) r]; fconfigure $fp -buffering line; gets $fp data
     set line 0;
     while {$data != ""} { incr line; gets $fp data; }
     flush stdout; close $fp
     set training(eline) $line;
     set training(status) on;
     set training(line) "0";


ttest;
}


bind pub - !menu training:showmenu

proc training:showmenu {nick uhost hand chan arg} {
 global training
 if {$training(status) == "on"} { return }
 set filename "/usr/home/assign/eggdrop/story/menu.txt"
 if {![file exists $filename]} { return }
 set training(host) $uhost;
 set training(nick) $nick;
 if {[isvoice $nick $chan] != "0"} { set training(nick) "doNOTdevoice" }
 set training(file) $filename;
 set training(fline) 0;
 set training(chan) $chan;

 set fp [open $training(file) r]; fconfigure $fp -buffering line; gets $fp data
 set line 0;
 while {$data != ""} { incr line; gets $fp data; }
 flush stdout; close $fp
 set training(eline) $line;
 set training(status) on;
 set training(line) "0";
 ttest2
}

proc ttest2 {} {
 global training
 if {$training(status) == "off"} { return; }
 set fp [open $training(file) r]
 fconfigure $fp -buffering line
 gets $fp data
 set line 0;
 set x $training(fline); incr x;
 while {$data != ""} {
  if {$line == $training(fline)} { set training(ammount) "[expr [string length $data] / 10]"; putserv "privmsg $training(chan) :$data"; };
  incr line;
  gets $fp data;
 }
 flush stdout; close $fp
 global training(line); incr training(line);
 if {$x > $training(eline)} { set training(status) "off"; return; }
 global training(fline); set training(fline) $x;
 set timertraining [utimer $training(ammount) ttest2];
}