BT.Topic.tcl 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ############################# TOPIC TCL #############################
  6. #########################################################################
  7. ## ##
  8. ## BlackTools : http://blacktools.tclscripts.net ##
  9. ## Bugs report : http://www.tclscripts.net/ ##
  10. ## Online Help : irc://irc.undernet.org/tcl-help ##
  11. ## #TCL-HELP / UnderNet ##
  12. ## You can ask in english or romanian ##
  13. ## ##
  14. #########################################################################
  15. proc topic:autotopic {nick host hand chan} {
  16. global black
  17. if {![validchan $chan]} { return }
  18. if {[setting:get $chan autotopic]} {
  19. utimer 5 [list topic:join:act $chan]
  20. }
  21. }
  22. proc topic:join:act {chan} {
  23. global black
  24. if {![botisop $chan]} {
  25. return
  26. }
  27. set gettopic ""
  28. set file [open $black(join_file) r]
  29. while {[gets $file line] != -1} {
  30. set read_modul [lindex [split $line] 0]
  31. set read_chan [lindex [split $line] 1]
  32. if {[string equal -nocase $read_modul "topic"] && [string equal -nocase $chan $read_chan]} {
  33. set read_msg [lrange [split $line] 2 end]
  34. set gettopic [encoding convertfrom utf-8 $read_msg]
  35. }
  36. }
  37. close $file
  38. if {$gettopic != ""} {
  39. set chantopic [topic $chan]
  40. if {$chantopic != $gettopic} {
  41. set url [setting:get $chan url]
  42. if {$url != ""} {
  43. putserv "TOPIC $chan :[join $gettopic] ($url)"
  44. } else { putserv "TOPIC $chan :[join $gettopic]" }
  45. }
  46. }
  47. }
  48. proc topic:return {chan} {
  49. global black
  50. set gettopic ""
  51. set file [open $black(join_file) r]
  52. while {[gets $file line] != -1} {
  53. set read_modul [lindex [split $line] 0]
  54. set read_chan [lindex [split $line] 1]
  55. if {[string equal -nocase $read_modul "topic"] && [string equal -nocase $chan $read_chan]} {
  56. set read_msg [lrange [split $line] 2 end]
  57. set gettopic [encoding convertfrom utf-8 $read_msg]
  58. }
  59. }
  60. close $file
  61. return $gettopic
  62. }
  63. proc topicpublic {nick host hand chan arg} {
  64. global black lastbind
  65. set who [lindex [split $arg] 0]
  66. set modul "topic"
  67. set type 0
  68. set chan1 $chan
  69. set topic [join [lrange [split $arg] 1 end]]
  70. if {[regexp {^[&#]} $who] && [matchattr $hand nmo|M $who]} {
  71. set chan $who
  72. set who [lindex [split $arg] 1]
  73. set topic [join [lrange [split $arg] 2 end]]
  74. }
  75. set return [blacktools:mychar $lastbind $hand]
  76. if {$return == "0"} {
  77. return
  78. }
  79. othermodule:process $nick $host $hand $chan $chan1 $who $topic $type $modul
  80. }
  81. ##############
  82. #########################################################################
  83. ## END ##
  84. #########################################################################