Misc.tcl 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #################################################################################
  2. # ngBot - Miscellaneous triggers #
  3. #################################################################################
  4. #
  5. # Description:
  6. #
  7. # Basic plugin to echo the output of a script to the channel. Like listaffils.sh
  8. #
  9. # Installation:
  10. # 1. Add the following to your eggdrop.conf:
  11. # source pzs-ng/plugins/Misc.tcl
  12. #
  13. # 2. Rehash or restart your eggdrop for the changes to take effect.
  14. #
  15. # Changelog:
  16. # - 20150216
  17. #
  18. #################################################################################
  19. namespace eval ::ngBot::plugin::Misc {
  20. variable ns [namespace current]
  21. variable np [namespace qualifiers [namespace parent]]
  22. variable misc
  23. variable scriptFile [info script]
  24. variable scriptName ${ns}::LogEvent
  25. ## Config Settings ###############################
  26. ##
  27. ## Channel
  28. set misc(chan) "#pzs-ng"
  29. set misc(listaffilstrigger) "!affils"
  30. set misc(prefix) "Affils: "
  31. ##
  32. ##################################################
  33. set misc(version) "20150216"
  34. proc init {args} {
  35. variable misc
  36. variable ns
  37. variable np
  38. variable scriptName
  39. variable scriptFile
  40. set theme_file [file normalize "[pwd]/[file rootname $scriptFile].zpt"]
  41. if {[file isfile $theme_file]} {
  42. ${np}::loadtheme $theme_file true
  43. }
  44. if {([info exists misc(listaffilstrigger)]) && (![string equal $misc(listaffilstrigger) ""])} {
  45. bind pub -|- $misc(listaffilstrigger) ${ns}::listAffils
  46. }
  47. putlog "\[ngBot\] Misc :: Loaded successfully (Version: $misc(version))."
  48. }
  49. proc deinit {args} {
  50. variable ns
  51. variable misc
  52. catch {unbind pub -|- $misc(listaffilstrigger) ${ns}::listAffils}
  53. namespace delete [namespace current]
  54. }
  55. proc listAffils {args} {
  56. variable misc
  57. if {[catch {exec /glftpd/bin/listaffils.sh} output] != 0} {
  58. putlog "\[ngBot\] Misc :: Error: Problem executing listaffils \"$output\""
  59. return
  60. }
  61. foreach line [split $output "\n"] {
  62. foreach chan [split $misc(chan)] {
  63. puthelp "PRIVMSG $chan :$misc(prefix) $line"
  64. }
  65. }
  66. }
  67. }