BT.Topic.tcl 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. ## GitHub page : https://github.com/tclscripts/BlackToolS-TCL ##
  11. ## Online Help : irc://irc.undernet.org/tcl-help ##
  12. ## #TCL-HELP / UnderNet ##
  13. ## You can ask in english or romanian ##
  14. ## ##
  15. #########################################################################
  16. proc topic:get {chan} {
  17. global black
  18. set getline ""
  19. set file [open $black(join_file) r]
  20. while {[gets $file line] != -1} {
  21. set read_modul [lindex [split $line] 0]
  22. set read_chan [lindex [split $line] 1]
  23. if {[string equal -nocase $read_modul "TOPIC"] && [string equal -nocase $chan $read_chan]} {
  24. set read_msg [join [lrange [split $line] 2 end]]
  25. set getline [encoding convertfrom utf-8 $read_msg]
  26. continue
  27. }
  28. }
  29. close $file
  30. return $getline
  31. }
  32. proc topic:autotopic {nick host hand chan} {
  33. global black
  34. if {![validchan $chan]} { return }
  35. if {[setting:get $chan autotopic]} {
  36. utimer 5 [list topic:join:act $chan]
  37. }
  38. }
  39. proc topic:join:act {chan} {
  40. global black
  41. if {![botisop $chan]} {
  42. return
  43. }
  44. set gettopic ""
  45. set file [open $black(join_file) r]
  46. while {[gets $file line] != -1} {
  47. set read_modul [lindex [split $line] 0]
  48. set read_chan [lindex [split $line] 1]
  49. if {[string equal -nocase $read_modul "topic"] && [string equal -nocase $chan $read_chan]} {
  50. set read_msg [lrange [split $line] 2 end]
  51. set gettopic [encoding convertfrom utf-8 $read_msg]
  52. }
  53. }
  54. close $file
  55. if {$gettopic != ""} {
  56. set chantopic [topic $chan]
  57. set url [join [setting:get $chan url]]
  58. if {$url != ""} {
  59. set chantopic [string map [list "($url)" ""] $chantopic]
  60. }
  61. if {![string equal -nocase [concat [color:filter $chantopic]] [concat [color:filter $gettopic]]]} {
  62. if {$url != ""} {
  63. putserv "TOPIC $chan :[join $gettopic] ($url)"
  64. } else { putserv "TOPIC $chan :[join $gettopic]" }
  65. }
  66. }
  67. }
  68. proc topic:return {chan} {
  69. global black
  70. set gettopic ""
  71. set file [open $black(join_file) r]
  72. while {[gets $file line] != -1} {
  73. set read_modul [lindex [split $line] 0]
  74. set read_chan [lindex [split $line] 1]
  75. if {[string equal -nocase $read_modul "topic"] && [string equal -nocase $chan $read_chan]} {
  76. set read_msg [lrange [split $line] 2 end]
  77. set gettopic [encoding convertfrom utf-8 $read_msg]
  78. }
  79. }
  80. close $file
  81. return $gettopic
  82. }
  83. ##############
  84. #########################################################################
  85. ## END ##
  86. #########################################################################