cims_interconnect_slave.tcl 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # CIMS: Community IRC Messaging Service
  2. # CIMS formerly known as MNET (Message Network)
  3. # Multiple Network Interconnection SLAVE Script
  4. # Copyright (C) 2004 Paul-Dieter Klumpp
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. # vim: expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
  20. namespace eval ::cims::interconnect {
  21. }
  22. # we get the count as a full message layout from the MASTER interconnect bot.
  23. proc ::cims::interconnect::reply_from_icmaster {rec_botnick cmd rec_data} {
  24. set tmp_network [join [lindex $rec_data 0]]
  25. set rec_network [::putils::kill_spaces $tmp_network]
  26. #putlog "network: '$network'"
  27. set tmp_name [join [lindex $rec_data 1]]
  28. #putlog "tmp_net: '$tmp_network'"
  29. #putlog "tmp_nam: '$tmp_name'"
  30. set rec_freqname [::putils::kill_spaces $tmp_name]
  31. #putlog "name: '$name'"
  32. set rec_source [join [lindex $rec_data 2]]
  33. set rec_text [join [lrange $rec_data 3 end]]
  34. #putlog "rec_text: '$rec_text'"
  35. set allowed [::cims::allowed_netbot $rec_network ${rec_botnick}]
  36. if {$allowed == 0} {
  37. return 0
  38. }
  39. # now the bot is declared as a known bot.
  40. putlog "SOURCE: $rec_source"
  41. set ::cims::interconnect::receive_count($rec_freqname,$rec_source) $rec_text
  42. #keep this valid for 15 seconds
  43. utimer 15 "unset ::cims::interconnect::receive_count($rec_freqname,$rec_source)"
  44. }
  45. # called right before the local output... INJECT it ;)
  46. proc ::cims::timeout_reply_from_local_for_netbots_plugin {freqname source} {
  47. upvar output output
  48. if {[info exists ::cims::interconnect::receive_count($freqname,$source)]} {
  49. set output "$output $::cims::interconnect::receive_count($freqname,$source)"
  50. }
  51. }
  52. # ========================================================================================
  53. proc ::cims::interconnect::bindings {} {
  54. bind bot - mnet_interconnect_answer ::cims::interconnect::reply_from_icmaster
  55. }
  56. proc ::cims::interconnect::main {} {
  57. putlog "mnet! = mnet interconnection SLAVE script loaded."
  58. ::cims::interconnect::bindings
  59. }
  60. namespace eval ::cims::interconnect {
  61. # timer weil $botnet-nick nicht sofort von eggdrop gesetzt wird
  62. utimer 3 "::cims::interconnect::main"
  63. }