Advertisement
Guest User

Untitled

a guest
Oct 8th, 2017
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 9.91 KB | None | 0 0
  1. # userinfo.tcl v1.06 for Eggdrop 1.4.3 and higher
  2. #           Scott G. Taylor -- ButchBub!staylor@mrynet.com
  3. #
  4. # $Id: userinfo.tcl,v 1.5 2001-11-15 06:28:35 guppy Exp $
  5. #
  6. # v1.00      ButchBub     14 July      1997 -Original release.  Based on
  7. #                                            whois.tcl "URL" commands.
  8. # v1.01      Beldin       11 November  1997 -1.3 only version
  9. # v1.02      Kirk         19 June      1998 -extremely small fixes
  10. # v1.03      guppy        17 March     1999 -small fixes again
  11. # v1.04      Ernst        15 June      1999 -fix for egg 1.3.x + TCL 8.0
  12. # v1.05      Dude         14 July      1999 -small cosmetic/typo fixes
  13. #                                           -$lastbind bug work around fix
  14. #                                           -added userinfo_loaded var
  15. #                                           -fixed bug in dcc_chuserinfo proc
  16. #                                           -unbinds removed user fields
  17. #                                           -dcc .showfields command added
  18. #                                           -deletes removed userinfo fields
  19. #                                            from the whois-fields list.
  20. # v1.06      guppy        19 March     2000 -removed lastbind workaround since
  21. #                                            lastbind is fixed in eggdrop1.4.3
  22. # v1.07      TaKeDa       20 August    2001 -now script works also on bots,
  23. #                                            which didn't have server module loaded
  24. #                                           -added new fields PHONE & ICQ
  25. #
  26. # TO USE:  o    Set the desired userinfo field keywords to the
  27. #               `userinfo-fields' line below where indicated.
  28. #          o    Load this script on a 1.1.6 or later Eggdrop bot.
  29. #          o    Begin having users save the desired information.  If you
  30. #               choose to add the default "IRL" field, they just use
  31. #               the IRC command: /MSG <botnick> irl Joe Blow.
  32. #          o    See the new information now appear with the whois command.
  33. #
  34. # This script enhances the `whois' output utilizing the `whois-fields'
  35. # option of eggdrop 1.1-grant and later versions.  It adds the functionality
  36. # of whois.tcl used in pre-1.1-grant versions.
  37. #
  38. # The fields desired to be maintained in the userfile `xtra' information
  39. # should be put in `userinfo-fields'.  This is different than the Eggdrop
  40. # configuration variable `whois-fields' in that this script will add the
  41. # commands to change these fields.   It will also add these desired fields
  42. # to the `whois-fields' itself, so do not define them there as well.  The
  43. # fields added in `userinfo-fields' will be converted to upper case for
  44. # aesthetics in the `whois' command output.
  45. #
  46. # The commands that will be added to the running eggdrop are:
  47. #  (<info> will be the respective userfile field added in `userinfo-fields')
  48. #
  49. #   TYPE    COMMAND         USAGE
  50. #   ======  ==============  ========================================
  51. #   msg      <info>         To change your <info> via /MSG.
  52. #   dcc     .<info>         To change your <info> via DCC.
  53. #   dcc     .ch<info>       To change someone else's <info> via DCC.
  54. #
  55. # Currently supported fields and commands:
  56. #
  57. #   FIELD   USAGE
  58. #   =====   =====================
  59. #   URL     WWW page URL
  60. #   IRL     In Real Life name
  61. #   BF      Boyfriend
  62. #   GF      Girlfriend
  63. #   DOB     Birthday (Date Of Birth)
  64. #   EMAIL   Email address
  65. #   PHONE   Phone number
  66. #   ICQ     ICQ number
  67.  
  68.  
  69. ################################
  70. # Set your desired fields here #
  71. ################################
  72.  
  73. set userinfo-fields "URL BF GF IRL EMAIL DOB PHONE ICQ"
  74.  
  75. # This script's identification
  76.  
  77. set userinfover "Userinfo TCL v1.07"
  78.  
  79. # This script is NOT for pre-1.4.3 versions.
  80.  
  81. catch { set numversion }
  82. if {![info exists numversion] || ($numversion < 1040300)} {
  83.   putlog "*** Can't load $userinfover -- At least Eggdrop v1.4.3 required"
  84.     return 0
  85. }
  86.  
  87. # Make sure we don't bail because whois and/or userinfo-fields aren't set.
  88.  
  89. if { ![info exists whois-fields]} { set whois-fields "" }
  90. if { ![info exists userinfo-fields]} { set userinfo-fields "" }
  91.  
  92. # Add only the userinfo-fields not already in the whois-fields list.
  93.  
  94. foreach field [string tolower ${userinfo-fields}] {
  95.  if { [lsearch -exact [string tolower ${whois-fields}] $field] == -1 } { append whois-fields " " [string toupper $field] }
  96. }
  97.  
  98. # If olduserinfo-fields doesn't exist, create it.
  99.  
  100. if { ![info exists olduserinfo-fields] } { set olduserinfo-fields ${userinfo-fields} }
  101.  
  102. # Delete only the userinfo-fields that have been removed but are still
  103. # listed in the whois-fields list.
  104.  
  105. foreach field [string tolower ${olduserinfo-fields}] {
  106.  if { [lsearch -exact [string tolower ${whois-fields}] $field] >= 0 && [lsearch -exact [string tolower ${userinfo-fields}] $field] == -1 } {
  107.   set fieldtmp [lsearch -exact [string tolower ${whois-fields}] $field]
  108.   set whois-fields [lreplace ${whois-fields} $fieldtmp $fieldtmp]
  109.  }
  110. }
  111.  
  112. # If olduserinfo-fields don't equal userinfo-fields, lets run through the
  113. # old list of user fields and compare them with the current list. this way
  114. # any fields that have been removed that were originally in the list will
  115. # have their msg/dcc commands unbinded so you don't have to do a restart.
  116.  
  117. if {[info commands putserv] == ""} {
  118.  set isservermod 0
  119. } else {
  120.  set isservermod 1
  121. }
  122.  
  123. if { [string tolower ${olduserinfo-fields}] != [string tolower ${userinfo-fields}] } {
  124.  foreach field [string tolower ${olduserinfo-fields}] {
  125.   if { [lsearch -exact [string tolower ${userinfo-fields}] $field] == -1 } {
  126.    if $isservermod {unbind msg - $field msg_setuserinfo}
  127.    unbind dcc - $field dcc_setuserinfo
  128.    unbind dcc m ch$field dcc_chuserinfo
  129.   }
  130.  }
  131.  set olduserinfo-fields ${userinfo-fields}
  132. }
  133.  
  134. # Run through the list of user info fields and bind their commands
  135.  
  136. if { ${userinfo-fields} != "" } {
  137.  foreach field [string tolower ${userinfo-fields}] {
  138.   if $isservermod {bind msg - $field msg_setuserinfo}
  139.   bind dcc - $field dcc_setuserinfo
  140.   bind dcc m ch$field dcc_chuserinfo
  141.  }
  142. }
  143.  
  144. # This is the `/msg <info>' procedure
  145. if $isservermod {
  146.  
  147. proc msg_setuserinfo {nick uhost hand arg} {
  148.   global lastbind quiet-reject userinfo-fields
  149.    set userinfo [string toupper $lastbind]
  150.   set arg [cleanarg $arg]
  151.   set ignore 1
  152.   foreach channel [channels] {
  153.     if {[onchan $nick $channel]} {
  154.       set ignore 0
  155.     }
  156.   }
  157.   if {$ignore} {
  158.     return 0
  159.   }
  160.    if {$hand != "*"} {
  161.       if {$arg != ""} {
  162.          if {[string tolower $arg] == "none"} {
  163.             putserv "NOTICE $nick :Removed your $userinfo line."
  164.             setuser $hand XTRA $userinfo ""
  165.          } {
  166.             putserv "NOTICE $nick :Now: $arg"
  167.             setuser $hand XTRA $userinfo "[string range $arg 0 159]"
  168.          }
  169.       } {
  170.          if {[getuser $hand XTRA $userinfo] == ""} {
  171.             putserv "NOTICE $nick :You have no $userinfo set."
  172.          } {
  173.             putserv "NOTICE $nick :Currently: [getuser $hand XTRA $userinfo]"
  174.          }
  175.       }
  176.    } else {
  177.       if {${quiet-reject} != 1} {
  178.         putserv "NOTICE $nick :You must be a registered user to use this feature."
  179.       }
  180.    }
  181.   putcmdlog "($nick!$uhost) !$hand! $userinfo $arg"
  182.   return 0
  183. }
  184.  
  185. #checking for server module
  186. }
  187.  
  188. # This is the dcc '.<info>' procedure.
  189.  
  190. proc dcc_setuserinfo {hand idx arg} {
  191.   global lastbind userinfo-fields
  192.     set userinfo [string toupper $lastbind]
  193.   set arg [cleanarg $arg]
  194.   if {$arg != ""} {
  195.     if {[string tolower $arg] == "none"} {
  196.       putdcc $idx "Removed your $userinfo line."
  197.       setuser $hand XTRA $userinfo ""
  198.     } {
  199.       putdcc $idx "Now: $arg"
  200.       setuser $hand XTRA $userinfo "[string range $arg 0 159]"
  201.     }
  202.   } {
  203.     if {[getuser $hand XTRA $userinfo] == ""} {
  204.       putdcc $idx "You have no $userinfo set."
  205.     } {
  206.       putdcc $idx "Currently: [getuser $hand XTRA $userinfo]"
  207.     }
  208.   }
  209.   putcmdlog "#$hand# [string tolower $userinfo] $arg"
  210.   return 0
  211. }
  212.  
  213. # This is the DCC `.ch<info>' procedure
  214.  
  215. proc dcc_chuserinfo {hand idx arg} {
  216.   global lastbind userinfo-fields
  217.    set userinfo [string toupper [string range $lastbind 2 end]]
  218.   set arg [cleanarg $arg]
  219.   if { $arg == "" } {
  220.     putdcc $idx "syntax: .ch[string tolower $userinfo] <who> \[<[string tolower $userinfo]>|NONE\]"
  221.     return 0
  222.   }
  223.   set who [lindex [split $arg] 0]
  224.   if {![validuser $who]} {
  225.     putdcc $idx "$who is not a valid user."
  226.     return 0
  227.   }
  228.   if {[llength [split $arg]] == 1} {
  229.     set info ""
  230.   } {
  231.     set info [lrange [split $arg] 1 end]
  232.   }
  233.   if {$info != ""} {
  234.     if {[string tolower $info] == "none"} {
  235.       putdcc $idx "Removed $who's $userinfo line."
  236.       setuser $who XTRA $userinfo ""
  237.       putcmdlog "$userinfo for $who removed by $hand"
  238.     } {
  239.       putdcc $idx "Now: $info"
  240.       setuser $who XTRA $userinfo "$info"
  241.       putcmdlog "$userinfo for $who set to \"$info\" by $hand"
  242.     }
  243.   } {
  244.     if {[getuser $who XTRA $userinfo] == ""} {
  245.       putdcc $idx "$who has no $userinfo set."
  246.     } {
  247.       putdcc $idx "Currently: [getuser $who XTRA $userinfo]"
  248.     }
  249.   }
  250.   return 0
  251. }
  252.  
  253. bind dcc m showfields showfields
  254.  
  255. proc showfields {hand idx arg} {
  256.  global userinfo-fields
  257.  if { ${userinfo-fields} == "" } {
  258.   putdcc $idx "Their is no user info fields set."
  259.   return 0
  260.  }  
  261.  putdcc $idx "Currently: [string toupper ${userinfo-fields}]"
  262.  putcmdlog "#$hand# showfields"
  263.  return 0
  264. }
  265.  
  266. proc cleanarg {arg} {
  267.   set response ""
  268.   for {set i 0} {$i < [string length $arg]} {incr i} {
  269.     set char [string index $arg $i]
  270.     if {($char != "\12") && ($char != "\15")} {
  271.       append response $char
  272.     }
  273.   }
  274.   return $response
  275. }
  276.  
  277. # Set userinfo_loaded variable to indicate that the script was successfully
  278. # loaded. this can be used in scripts that make use of the userinfo tcl.
  279.  
  280. set userinfo_loaded 1
  281.  
  282. # Announce that we've loaded the script.
  283.  
  284. putlog "$userinfover loaded (${userinfo-fields})."
  285. putlog "use '.help userinfo' for commands."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement