BT.Topic.tcl 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. set url [setting:get $chan url]
  41. if {$url != ""} {
  42. set chantopic [string map [list "($url)" ""] $chantopic]
  43. }
  44. if {![string equal -nocase [concat [color:filter $chantopic]] [concat [color:filter $gettopic]]]} {
  45. if {$url != ""} {
  46. putserv "TOPIC $chan :[join $gettopic] ($url)"
  47. } else { putserv "TOPIC $chan :[join $gettopic]" }
  48. }
  49. }
  50. }
  51. proc topic:return {chan} {
  52. global black
  53. set gettopic ""
  54. set file [open $black(join_file) r]
  55. while {[gets $file line] != -1} {
  56. set read_modul [lindex [split $line] 0]
  57. set read_chan [lindex [split $line] 1]
  58. if {[string equal -nocase $read_modul "topic"] && [string equal -nocase $chan $read_chan]} {
  59. set read_msg [lrange [split $line] 2 end]
  60. set gettopic [encoding convertfrom utf-8 $read_msg]
  61. }
  62. }
  63. close $file
  64. return $gettopic
  65. }
  66. ##############
  67. #########################################################################
  68. ## END ##
  69. #########################################################################