2019-10m-9d-modules-disaster.txt (6935B)
1 Hi, I'm ellenor@umbrellix.net, and I figured I needed to explain this disaster. 2 3 [perihelion ellenor]~/src/asterIRC/tclserv/modules $ ls -lah 4 total 97 5 drwxr-xr-x 2 ellenor other 16 Oct 7 22:58 . 6 drwxr-xr-x 7 ellenor other 23 Oct 9 15:40 .. 7 -rwxr-xr-x 1 ellenor other 209 Oct 6 00:02 bmotion.disabled 8 -rwxr-xr-x 1 ellenor other 17.2K Oct 7 22:43 chanserv.disabled 9 -rw-r--r-- 1 ellenor other 2.83K Oct 7 22:58 chanserv.tcl 10 -rw-r--r-- 1 ellenor other 5.01K Oct 6 00:02 debugserv.tcl 11 -rwxr-xr-x 1 ellenor other 3.73K Oct 6 00:02 gateway.disabled 12 -rwxr-xr-x 1 ellenor other 2.87K Oct 6 00:02 limitserv.disabled 13 -rwxr-xr-x 1 ellenor other 13.7K Oct 6 00:02 nope.egg.nope 14 -rwxr-xr-x 1 ellenor other 4.12K Oct 6 00:02 quote.disabled 15 -rw-r--r-- 1 ellenor other 13.8K Oct 6 00:02 quoteserv.tcl 16 -rwxr-xr-x 1 ellenor other 534 Oct 6 00:02 relayserv.disabled 17 -rwxr-xr-x 1 ellenor other 2.06K Oct 6 00:02 thcserv.disabled 18 -rwxr-xr-x 1 ellenor other 3.54K Oct 6 00:02 trigserv.disabled 19 -rwxr-xr-x 1 ellenor other 12.9K Oct 6 00:02 weather.disabled 20 -rw-r--r-- 1 ellenor other 16.6K Oct 6 00:02 weather.tcl 21 22 Figure 1. $PROJECT_ROOT/modules/ 23 24 In figure 1, you can see that there are 10 disabled modules (one of which has 25 a comical name owing to that it's an ancestor of, I believe, 26 core/*-eggcom.tcl). Many of these are services for the old API, which used 27 a different structure of boilerplate code which you can see in 28 modules/chanserv.disabled. That was also a multi-network API, but it was not 29 actually working for TclServ anymore, so it has been migrated to the version 30 2 API which you can see in all of the modules whose extension is .tcl. 31 32 proc confighandler {servicename defdbname headline block} { 33 set net [lindex $headline 0] 34 set nsock $::sock($net) 35 dictassign $block nick nick ident ident host host realname realname 36 if {[llength [tnda get "service/$net/$servicename/config"]] != 0} { 37 return -code error "<$servicename> O damn, I'm already loaded for $net! 38 } 39 tnda set "service/$net/$servicename/config" $block 40 if {[tnda get "service/$net/$servicename/config/dbname"] == ""} { 41 tnda set "service/$net/$servicename/dbname" $defdbname 42 } 43 setctx $net 44 if {[% intclient2uid [tnda get "service/$net/$servicename/ourid"]] == ""} {% sendUid $nick $ident $host $host [set ourid [% getfreeuid]] [expr {($realname == "") ? "* $servicename *" : $realname}] $modes; set connected "Connected"} {set connected "Already connected"} 45 set ouroid [tnda get "service/$net/$servicename/ourid"] 46 if {[info exists ourid]} {tnda set "service/$net/$servicename/ourid" $ourid} {set ourid [tnda get "service/$net/$servicename/ourid"]} 47 puts stdout [format "%s for %s: %s %s %s" $connected $net $nick $ident $host] 48 } 49 50 Figure 2. Suggested new structure of the boilerplate code for handling a 51 configuration block. 52 53 The code in Figure 2, for reference, is part of the boilerplate code that is 54 usually used by API level 2 modules. 55 56 $::maintype sendUid $::sock($::cs(netname)) $cs(nick) $cs(ident) $cs(host) $cs(host) 77 "Channels Server" 57 bind $::sock($::cs(netname)) msg 77 "register" regchan 58 bind $::sock($::cs(netname)) msg 77 "adduser" adduserchan 59 bind $::sock($::cs(netname)) msg 77 "users" lsuchan 60 bind $::sock($::cs(netname)) msg 77 "lsu" lsuchan 61 bind $::sock($::cs(netname)) msg 77 "convertop" convertop 62 #bind $::sock($::cs(netname)) msg 77 "deluser" deluserchan 63 bind $::sock($::cs(netname)) msg 77 "up" upchan 64 bind $::sock($::cs(netname)) pub "-" "@up" upchanfant 65 bind $::sock($::cs(netname)) pub "-" "@rand" randfant 66 bind $::sock($::cs(netname)) pub "-" "@request" requestbot 67 bind $::sock($::cs(netname)) msg 77 "down" downchan 68 bind $::sock($::cs(netname)) msg 77 "hello" regnick 69 bind $::sock($::cs(netname)) msg 77 "chpass" chpassnick 70 bind $::sock($::cs(netname)) msg 77 "login" idnick 71 bind $::sock($::cs(netname)) msg 77 "help" chanhelp 72 bind $::sock($::cs(netname)) msg 77 "topic" chantopic 73 bind $::sock($::cs(netname)) msg 77 "cookie" authin 74 bind $::sock($::cs(netname)) msg 77 "cauth" cookieauthin 75 bind $::sock($::cs(netname)) mode "-" "+" checkop 76 bind $::sock($::cs(netname)) mode "-" "-" checkdeop 77 bind $::sock($::cs(netname)) topic "-" "-" checktopic 78 bind $::sock($::cs(netname)) create "-" "-" checkcreate 79 80 Figure 3. chanserv.disabled | head -n 23. 81 Note fixed UID, leaving no room to have two of the module on the same 82 IRC server (though why would you), and fixed variable names, leaving no 83 room to have two of the module in the first place. (in either case you 84 do only load once, and the same code routines are called for every 85 instance of the module). Configuration was simply not flexible to 86 multiple instantiation (which the new boilerplate still is not, but 87 can easily be made so) and was not consolidated into one file, but 2, 88 just as in "Featherdrop" (our attempt at a lightweight Eggdrop replica 89 in Tcl; replaced by adoption of FireEgl's Tcldrop). 90 91 The code in figure 3 is representative of a complex service. As a sidenote, 92 in modern TclServ, 'bind' is now Eggdrop emulation. 'llbind' would be 93 substituted to make that ChanServ (which we on then AsterIRC called 'Mars') 94 work on modern Tclserv. 95 96 proc % {c args} { 97 set ul [list [curctx proto] $c [curctx sock]] 98 foreach {a} $args {lappend ul $a} 99 uplevel 1 $ul 100 } 101 102 proc @@ {c args} { 103 set ul [list [curctx proto] $c [curctx sock] [curctx unum]] 104 foreach {a} $args {lappend ul $a} 105 uplevel 1 $ul 106 } 107 108 Figure 4. Convenience functions in core/4000-eggcom.tcl 109 110 Bizarrely, 4000-eggcom has morphed into a convenience functions module (it is 111 a core module and all installations of TclServ must load it, or the bot will 112 NOT function correctly) - its name suggests that it should only contain 113 eggdrop-compatibility functions, and that was the original purpose of that 114 file. By the time you read this file, it'll have been renamed to 115 4000-convenience, reflecting its function. Many functions in 4000-convenience 116 are obsolete, holdovers from the days of Mars and the old TclServ. 117 118 Please see modules/chanserv.tcl to look into efforts to make a more model- 119 compliant channels service module, that may eventually implement everything 120 that Mars did (including cookie auth, using a different algorithm). 121 122 In future, scripts that look like Eggdrop scripts but are only for TclServ 123 (the aim being to make it easier to port scripts from Eggdrop to TclServ, not 124 necessarily to make them run unmodified) will be in the scripts/ directory, 125 as might a way to make some script modules partially work in Eggdrop (by 126 translating the %/@@ commands to appropriate puthelps/putwhatevers, and 127 blanking the setctx commands if not running in an sBNC (after which our 128 inspiration for the context system was drawn)).