I did not bother to name this...

From Sharp Pheasant, 1 Month ago, written in TCL/iTCL, viewed 50 times. This paste will croak in 1 Second.
URL http://codebin.org/view/0c27db12 Embed
Download Paste or View Raw
  1. ###
  2. ## Name:            auth.tcl v0.02.01
  3. ## Author:          krimson
  4. ## Info:            Auth with X/Q on UnderNet/QuakeNet upon connect and sets usermodes on bot before joining channels
  5. #
  6. ## Features:
  7. #            This script makes the bot login automatically with X/Q from UnderNet/QuakeNet
  8. #            immediately after connecting to the server. It also performs definable usermodes
  9. #            before logging in.
  10. #
  11. ## Thanks to:       caesar @ undernet #botlending
  12. #
  13. ## Contact:
  14. #            mail:  krimsonlord@yahoo.com
  15. #            irc:   krimson@undernet/quakenet#botlending
  16. #
  17. ## Setup:
  18. #            change the values in "set data" with your user and password
  19. #            after that, all you have to do is copy the script in scripts/ dir
  20. #            and load it AT THE END of eggdrop.conf
  21. #            ike this:
  22. #                "source scripts/auth.tcl"
  23. #
  24. ## Changelog:
  25. #
  26. #        v0.02.01 - bugfix release
  27. #        v0.02.00 - rewritten most of the code
  28. #                 - now using namespace to prevent variable collision
  29. #                 - now checking if X/Q exists in userfile with +f - if not, add them with +f flag
  30. #        v0.01.02 - changed auto-detection of network - now detecting directly from irc server upon connect
  31. #                 - added on join event (in case X/Q was split, the bot now auths when they join a channel the bot is on)
  32. #        v0.01.01 - minor event bug fixes
  33. #                 - simplified the procedures
  34. #        v0.01.00 - added auto-detection of network name from eggdrop's config file
  35. #                 - rewritten verification process
  36. #                 - the eggdrop doesn't .die anymore if it's on the wrong network. it just skips the whole script and leaves a warning in logs
  37. #                 - added another failed event (in case the server the bot is on is split from the rest of the network and X or Q is gone missing, the bot will join all channels)
  38. #        v0.00.03 - removed secondary auth attempts
  39. #                 - added failed event (in case the bot doesn't login), so that it won't stay out of all channels forever.
  40. #        v0.00.02 - fixed endless looping of auth attempts (if it happend to not auth from the first try)
  41. #                 - extended script for quakenet
  42. ###
  43.  
  44. namespace eval services:auth:00201 {
  45.  
  46. ###
  47. #  Begin Config
  48. ###
  49.  
  50. ## set the username and password the bot will use (space separated)
  51.  set data "sentinel "
  52.  
  53. ## set the modes applied on connection
  54.  set modes "+ix-wds"
  55.  
  56. ###
  57. #  END Config
  58. ###
  59.  
  60. #########################################
  61. #!!!!!!DO NOT EDIT AFTER THIS LINE!!!!!!#
  62. #########################################
  63.  
  64. if {[llength $data] != 2} return
  65.  
  66. set services(user) [lindex $data 0]
  67. set services(password) [lindex $data 1]
  68.  
  69.         proc switch:active {arg} {
  70.         if {![llength $arg]} {
  71.             return
  72.         } elseif {!$arg} {
  73.             set mode "-inactive"
  74.         } else {
  75.             set mode "+inactive"
  76.         }
  77.         foreach chan [channels] {
  78.             channel set $chan $mode
  79.     }
  80.     }
  81.     bind raw - 001 [namespace current]::on:connect
  82.    
  83.     proc on:connect {from keyword text} {
  84.         variable services
  85.             switch -- "[string tolower [lindex $text 4]]" {
  86.                 "average.network" { set services(nick) "X"
  87.                              set services(host) "X!cservice@average.network"
  88.                              set services(login) "X@services.average.network"
  89.                              set services(word) "login"
  90.                              set services(success) "AUTHENTICATION SUCCESSFUL*"
  91.                              set services(failed) "AUTHENTICATION FAILED*"
  92.                              set services(status) "Successfully LOGGED in to X"
  93.                              check:serv
  94.                             }
  95.                 "quakenet" { set services(nick) "Q"
  96.                              set services(host) "Q!TheQBot@CServe.quakenet.org"
  97.                              set services(login) "Q@CServe.quakenet.org"
  98.                              set services(word) "auth"
  99.                              set services(success) "AUTH'd successfully*"
  100.                              set services(failed) "Username or password incorrect*"
  101.                              set services(status) "Successfully AUTH'd with Q"
  102.                              check:serv
  103.                             }
  104.                 default { putlog "Eggdrop not connected to Quakenet or Average.Network. Skipping auth.tcl..." }
  105.             }
  106.     }
  107.    
  108.     proc check:serv {args} {
  109.         variable services
  110.            
  111.             if {![matchattr $services(nick) f]} {
  112.                 if {![validuser $services(nick)]} {
  113.                     adduser $services(nick) $services(host)
  114.                     putlog "Didn't find $services(nick) in userlist. Succesfuly added $services(nick) to userlist"
  115.                 }
  116.                     chattr $services(nick) +f
  117.                     putlog "$services(nick) didn't have +f flag. Succesfuly added flag +f to $services(nick)"
  118.                 }
  119.         auth:attempt
  120.     }
  121.    
  122.     proc auth:attempt {args} {
  123.         global botnick; variable services; variable modes; variable data;
  124.        
  125.             putquick "MODE $botnick $modes"
  126.             switch:active 1    
  127.            
  128.             putquick "PRIVMSG $services(login) :$services(word) $services(user) $services(password)" -next
  129.            
  130.             bind notc f|- "$services(success)" [namespace current]::auth:success
  131.             bind raw - 401 [namespace current]::services:split
  132.             bind notc f|- "$services(failed)" [namespace current]::auth:failed
  133.     }
  134.  
  135.     proc auth:success {nick uhost hand text dest} {
  136.         variable services
  137.        
  138.             if {$nick == $services(nick)} {
  139.                 unbind notc - "$services(success)" [namespace current]::auth:success
  140.                 unbind raw - 401 [namespace current]::services:split
  141.                 unbind raw - 001 [namespace current]::on:connect
  142.                 switch:active 0
  143.                 putlog "$services(status)"
  144.             }
  145.     }
  146.    
  147.     proc services:split {args} {
  148.         variable services
  149.            
  150.             putlog "Services bot $services(nick) is split. Skipping auth and joining channels..."
  151.             switch:active 0
  152.             bind join f|- "* $services(host)" [namespace current]::auth:on:join
  153.     }
  154.            
  155.     proc auth:on:join {nick uhost hand chan} {
  156.         variable services; variable data
  157.  
  158.         putquick "PRIVMSG $services(login) :$services(word) $services(user) $services(password)"
  159.  
  160.     }
  161.    
  162.     proc auth:failed {args} {
  163.         variable services
  164.             if {[string match -nocase "[lindex $args 1]" "[lindex [split $services(host) !] 1]"]} {
  165.            
  166.                 unbind raw - 401 [namespace current]::services:split
  167.                 unbind notc - "$services(failed)" [namespace current]::auth:failed
  168.                 switch:active 0
  169.                 putlog "Logging in to $services(nick) FAILED. Bogus user and/or pass. Rejoining chans..."
  170.             }
  171.     }
  172. putlog "LOADED v0.02.01 by krimson"
  173. }
  174.  

Reply to "I did not bother to name this..."

Here you can reply to the paste above