/[tcldrop]/tcldrop/modules/irc/irc.tcl
ViewVC logotype

Diff of /tcldrop/modules/irc/irc.tcl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by fireegl, Wed May 21 04:26:23 2003 UTC revision 1.8 by Papillon, Wed May 21 07:55:18 2003 UTC
# Line 334  proc ::tcldrop::irc::352 {from key arg} Line 334  proc ::tcldrop::irc::352 {from key arg}
334          return 0          return 0
335  }  }
336    
   
337  # irc.choopa.net: 352 FireEgl #channel ~FireEgl adsl-17-134-83.bhm.bellsouth.net irc.choopa.net FireEgl H@ 0 Proteus  # irc.choopa.net: 352 FireEgl #channel ~FireEgl adsl-17-134-83.bhm.bellsouth.net irc.choopa.net FireEgl H@ 0 Proteus
338  # Process the results from WHO $channel:  # Process the results from WHO $channel:
339  bind raw - 352 ::tcldrop::irc::352 99  bind raw - 352 ::tcldrop::irc::352 99
340  # Note: Proc by Papillon@EFNet.  # Note: Proc by Papillon@EFNet.
341  # FixMe: This is untested and unmodified.  # FixMe: This is untested and unmodified.
342  # FixMe: The original proc is above, it should be removed once this one has been tested/tweaked.  # FixMe: The original proc is above, it should be removed once this one has been tested/tweaked.
343    # This command seems to work good now
344  proc ::tcldrop::irc::352 {from key arg} {  proc ::tcldrop::irc::352 {from key arg} {
345          set larg [split $arg]          set larg [split $arg]
346          set channel [string tolower [lindex $larg 1]]          set channel [string tolower [lindex $larg 1]]
# Line 348  proc ::tcldrop::irc::352 {from key arg} Line 348  proc ::tcldrop::irc::352 {from key arg}
348          set address [lindex $larg 3]          set address [lindex $larg 3]
349          #set server [lindex $larg 4]          #set server [lindex $larg 4]
350          set nick [lindex $larg 5]          set nick [lindex $larg 5]
351          # Means H = Here and G = Gone * might appear aswell, this means that user is ircop          set flags [string trimleft [lindex $larg 6] {HG*xXd!}]
352          # x = user is logged in (ie as when he/she is logged into X on Undernet )--- Papillon          #set hops [string trimleft [lindex $larg 7] :]
         set flags [string trimleft [lindex $larg 6] {HG*xX}]  
         # How many "hops" the user is away from your connection, something like how many "hubs" there is between you and nick --- Papillon  
         set hops [lindex $larg 7]  
353          set realname [join [lrange $larg 8 end]]          set realname [join [lrange $larg 8 end]]
354          # Nicks stores global nick info:  
355          variable Nicks          # Nicks stores global nick info (not bot-info, we got that already):
356          set element [string tolower $nick]          if {![string equal $nick $::botnick]} {
357          array set nickinfo [array get Nicks $element]                  variable Nicks
358          array set nickinfo [list nick $nick ident $ident address $address realname $realname]                  set element [string tolower $nick]
359          set Nicks($element) [array get nickinfo]                  array set nickinfo [array get Nicks $element]
360                    array set nickinfo [list nick $nick ident $ident address $address realname $realname]
361                    set Nicks($element) [array get nickinfo]
362            }
363    
364          # ChannelNicks stores channel specific info on nicks:          # ChannelNicks stores channel specific info on nicks:
365          variable ChannelNicks          variable ChannelNicks
366          set element [string tolower "$channel,$nick"]          set element [string tolower "$channel,$nick"]
367          array set channick [array get ChannelNicks $element]          array set channick [array get ChannelNicks $element]
368          set op 0          set op 0
369          set voice 0          set voice 0
370            set halfop 0
371          foreach f $flags {          foreach f $flags {
372                  switch -- $f {                  switch -- $f {
373                          {@} { set op 1 }                          {@} { set op 1 }
374                          {+} { set voice 1 }                          {+} { set voice 1 }
375                            {%} { set halfop 1 }
376                  }                  }
377          }          }
378          array set channick [list nick $nick op $op voice $voice]          array set channick [list nick $nick op $op voice $voice halfop $halfop]
379          set ChannelNicks($element) [array get channick]          set ChannelNicks($element) [array get channick]
380          return 0          return 0
381  }  }
382    
# Line 382  bind raw - PART ::tcldrop::irc::PART 99 Line 385  bind raw - PART ::tcldrop::irc::PART 99
385  proc ::tcldrop::irc::PART {from key arg} {  proc ::tcldrop::irc::PART {from key arg} {
386          set who $from          set who $from
387          set channel $arg          set channel $arg
388            # remove the channel-specific info on $who
389            variable ChannelNicks
390            set element [string tolower "$channel,$who"]
391            array unset ChannelNicks $element
392          #chanrem [lindex $a 2]          #chanrem [lindex $a 2]
393  }  }
394    
# Line 619  proc ::tcldrop::irc::topic {channel} { Line 626  proc ::tcldrop::irc::topic {channel} {
626  #  botisop [channel]  #  botisop [channel]
627  #    Returns: 1 if the bot has ops on the specified channel (or any channel  #    Returns: 1 if the bot has ops on the specified channel (or any channel
628  #      if no channel is specified); 0 otherwise  #      if no channel is specified); 0 otherwise
629  proc ::tcldrop::irc::botisop {{channel {*}}} { isop $::botnick $channel }  proc ::tcldrop::irc::botisop {{channel {*}}} { ::tcldrop::irc::issomething $::botnick $channel op}
630    
631  #| botishalfop [channel]  #| botishalfop [channel]
632  #|   Returns: 1 if the bot has halfops on the specified channel (or any channel  #|   Returns: 1 if the bot has halfops on the specified channel (or any channel
633  #|     if no channel is specified); 0 otherwise  #|     if no channel is specified); 0 otherwise
634  proc ::tcldrop::irc::botishalfop {{channel {*}}} { ishalfop $::botnick $channel }  proc ::tcldrop::irc::botishalfop {{channel {*}}} { ::tcldrop::irc::issomething $::botnick $channel halfop}
635    
636  #  botisvoice [channel]  #  botisvoice [channel]
637  #    Returns: 1 if the bot has a voice on the specified channel (or any  #    Returns: 1 if the bot has a voice on the specified channel (or any
638  #      channel if no channel is specified); 0 otherwise  #      channel if no channel is specified); 0 otherwise
639  proc ::tcldrop::irc::botisvoice {{channel {*}}} { isvoice $::botnick $channel }  proc ::tcldrop::irc::botisvoice {{channel {*}}} { ::tcldrop::irc::issomething $::botnick $channel voice}
640    
641  #  isop <nickname> [channel]  #  isop <nickname> [channel]
642  #    Returns: 1 if someone by the specified nickname is on the channel (or  #    Returns: 1 if someone by the specified nickname is on the channel (or
643  #      any channel if no channel name is specified) and has ops; 0 otherwise  #      any channel if no channel name is specified) and has ops; 0 otherwise
644  proc ::tcldrop::irc::isop {nick {channel {*}}} {  proc ::tcldrop::irc::isop {nick {channel {*}}} { ::tcldrop::irc::issomething $nick $channel op }
 }  
645    
646  #| ishalfop <nickname> [channel]  #| ishalfop <nickname> [channel]
647  #|   Returns: 1 if someone by the specified nickname is on the channel (or  #|   Returns: 1 if someone by the specified nickname is on the channel (or
648  #|     any channel if no channel name is specified) and has halfops; 0 otherwise  #|     any channel if no channel name is specified) and has halfops; 0 otherwise
649  proc ::tcldrop::irc::ishalfop {nick {channel {*}}} {  proc ::tcldrop::irc::ishalfop {nick {channel {*}}} { ::tcldrop::irc::issomething $nick $channel halfop }
 }  
650    
651  #  wasop <nickname> <channel>  #  wasop <nickname> <channel>
652  #    Returns: 1 if someone that just got opped/deopped in the chan had op  #    Returns: 1 if someone that just got opped/deopped in the chan had op
# Line 658  proc ::tcldrop::irc::washalfop {nick cha Line 663  proc ::tcldrop::irc::washalfop {nick cha
663  #  isvoice <nickname> [channel]  #  isvoice <nickname> [channel]
664  #    Returns: 1 if someone by that nickname is on the channel (or any  #    Returns: 1 if someone by that nickname is on the channel (or any
665  #      channel if no channel is specified) and has voice (+v); 0 otherwise  #      channel if no channel is specified) and has voice (+v); 0 otherwise
666  proc ::tcldrop::irc::isvoice {nick {channel {*}}} {  proc ::tcldrop::irc::isvoice {nick {channel {*}}} { ::tcldrop::irc::issomething $nick $channel voice }
667  }  
668    # NOTE: made this proc to handle the (bot)isop/voice/halfop commands, to keep the filesize as small as possible ;)
669    proc ::tcldrop::irc::issomething {nick channel type} {
670            variable ChannelNicks
671            # FixMe Maybe we should make it return 0 if channel was enterd and it's not a valid channel,
672            # ...or just ignore it and check all channels? -eggdrop gives a tcl-error
673            set element [string tolower $channel,$nick]
674            foreach el [array names ChannelNicks $element] {
675                    array set channick [array get ChannelNicks $el]
676                    if {$channick($type) == 1} { set found 1; break }
677                    array unset channick
678            }
679            return [info exists found]
680    }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26