/[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.15 by fireegl, Sun May 25 11:18:24 2003 UTC revision 1.16 by Papillon, Tue May 27 09:59:39 2003 UTC
# Line 42  namespace eval ::tcldrop::irc { Line 42  namespace eval ::tcldrop::irc {
42          variable PushModes          variable PushModes
43          array set PushModes {}          array set PushModes {}
44          # Export all the commands that should be available to 3rd-party scripters:          # Export all the commands that should be available to 3rd-party scripters:
45          namespace export resetchan onchan botonchan nick2hand hand2nick handonchan getchanhost getchanjoin onchansplit chanlist getchanidle getchanmode pushmode flushmode topic botisop botishalfop botisvoice isop ishalfop wasop washalfop isvoice          namespace export resetchan onchan botonchan nick2hand hand2nick handonchan getchanhost getchanjoin onchansplit chanlist getchanidle getchanmode pushmode flushmode topic botisop botishalfop botisvoice isop ishalfop wasop washalfop isvoice ischanban ischanexempt ischaninvite chanbans chanexempts chaninvites resetbans resetexempts resetinvites
46  }  }
47    
48  proc ::tcldrop::irc::resetchan {channel} {  proc ::tcldrop::irc::resetchan {channel} {
# Line 251  proc ::tcldrop::irc::JOIN {from key arg} Line 251  proc ::tcldrop::irc::JOIN {from key arg}
251          set element [string tolower $channel,$nick]          set element [string tolower $channel,$nick]
252          if {![info exists Nicks([string tolower $nick])]} {          if {![info exists Nicks([string tolower $nick])]} {
253                  putserv "WHOIS $nick"                  putserv "WHOIS $nick"
254                  array set blabla [list nick $nick op 0 voice 0 halfop 0]                  array set blabla [list nick $nick op 0 voice 0 halfop 0 "join" [set m [clock seconds]] "idle" $m]
255                  set ChannelNicks($element) [array get blabla]                  set ChannelNicks($element) [array get blabla]
256          }          }
257          # Call all the join binds:          # Call all the join binds:
# Line 266  proc ::tcldrop::irc::JOIN {from key arg} Line 266  proc ::tcldrop::irc::JOIN {from key arg}
266          }          }
267  }  }
268    
269    #irc.blessed.net 367 TiCkLe #tclsh host*!*@jaslkgsdg CB-4!surf@80.199.114.234 1053610707
270  # Process the results of MODE $channel +b:  # Process the results of MODE $channel +b:
271  bind raw - 367 ::tcldrop::irc::367 99  bind raw - 367 ::tcldrop::irc::367 99
272  proc ::tcldrop::irc::367 {from key arg} {  proc ::tcldrop::irc::367 {from key arg} {
# Line 275  proc ::tcldrop::irc::367 {from key arg} Line 276  proc ::tcldrop::irc::367 {from key arg}
276          set creator [lindex $larg 3]          set creator [lindex $larg 3]
277          set created [lindex $larg 4]          set created [lindex $larg 4]
278          # FixMe: Complete this.          # FixMe: Complete this.
279            # We need to make a second ban-array to seperate the bans on channel, and the
280            # internal bans set by the bot (active or not)
281          variable Bans          variable Bans
282                    set element [string tolower $channel,$ban]
283            if {![info exists Bans($element]} { set Bans($element {} }
284            array set chanbans $Bans($element)
285            array set chanbans [list ban $ban creator $creator created $created]
286            set Bans($element) [array get chanbans]
287  }  }
288    
289    
# Line 420  proc ::tcldrop::irc::nick {nick uhost ha Line 427  proc ::tcldrop::irc::nick {nick uhost ha
427          }          }
428  }  }
429    
 # Proc by Papillon@EFNet  
430  bind raw - QUIT ::tcldrop::irc::SIGN 99  bind raw - QUIT ::tcldrop::irc::SIGN 99
431  proc ::tcldrop::irc::SIGN {from key arg} {  proc ::tcldrop::irc::SIGN {from key arg} {
432          set nick [lindex [split $from !] 0]          set nick [lindex [split $from !] 0]
# Line 428  proc ::tcldrop::irc::SIGN {from key arg} Line 434  proc ::tcldrop::irc::SIGN {from key arg}
434          set msg [string range $arg 1 end]          set msg [string range $arg 1 end]
435          set handle [finduser $uhost]          set handle [finduser $uhost]
436    
         set el [string tolower $nick]  
         variable Nicks  
         array unset Nicks $element  
         variable ChannelNicks  
         array unset ChannelNicks *,$element  
   
437          # Call all the sign binds:          # Call all the sign binds:
438          foreach b [binds sign] {          foreach b [binds sign] {
439                  foreach {type flags mask count proc} $b {}                  foreach {type flags mask count proc} $b {}
# Line 446  proc ::tcldrop::irc::SIGN {from key arg} Line 446  proc ::tcldrop::irc::SIGN {from key arg}
446                          }                          }
447                  }                  }
448          }          }
449            set element [string tolower $nick]
450            variable Nicks
451            array unset Nicks $element
452            variable ChannelNicks
453            array unset ChannelNicks *,$element
454  }  }
455    
456    
 #Papillon!~surf@193.69.194.13 KICK #tclsh PAx0 :Papillon  
457  bind raw - KICK ::tcldrop::irc::KICK 99  bind raw - KICK ::tcldrop::irc::KICK 99
458  proc ::tcldrop::irc::KICK {from key arg} {  proc ::tcldrop::irc::KICK {from key arg} {
459          set larg [split $arg]          set larg [split $arg]
# Line 486  proc ::tcldrop::irc::KICK {from key arg} Line 490  proc ::tcldrop::irc::KICK {from key arg}
490  # irc.choopa.net: 433 FireEgl NewNick Nickname is already in use.  # irc.choopa.net: 433 FireEgl NewNick Nickname is already in use.
491  # will choose the alternate nick, if that's taken aswell it will set Lamestbotxx  # will choose the alternate nick, if that's taken aswell it will set Lamestbotxx
492  # where xx is random numbers  # where xx is random numbers
 # Proc by Papillon@EFNet  
493  bind raw - 433 ::tcldrop::irc::433 99  bind raw - 433 ::tcldrop::irc::433 99
494  proc ::tcldrop::irc::433 {from key arg} {  proc ::tcldrop::irc::433 {from key arg} {
495          set oldnick [lindex [split $arg] 1]          set oldnick [lindex [split $arg] 1]
# Line 528  proc ::tcldrop::irc::352 {from key arg} Line 531  proc ::tcldrop::irc::352 {from key arg}
531          variable ChannelNicks          variable ChannelNicks
532          set element [string tolower "$channel,$nick"]          set element [string tolower "$channel,$nick"]
533          array set channick [array get ChannelNicks $element]          array set channick [array get ChannelNicks $element]
534            if {![info exists ChannelNicks($element)]} { array set channick [list idle [set m [clock seconds]] "join" $m] }
535          set op 0          set op 0
536          set voice 0          set voice 0
537          set halfop 0          set halfop 0
# Line 553  proc ::tcldrop::irc::PART {from key arg} Line 557  proc ::tcldrop::irc::PART {from key arg}
557          set msg [string range [join [lrange $larg 1 end]] 1 end]          set msg [string range [join [lrange $larg 1 end]] 1 end]
558          set handle [finduser $uhost]          set handle [finduser $uhost]
559    
         variable ChannelNicks  
         set element [string tolower "$channel,$nick"]  
         array unset ChannelNicks $element  
         if {[array get ChannelNicks [string tolower *,$nick]] == {}} {  
                 variable Nicks  
                 array unset Nicks [string tolower $nick]  
         }  
560          #chanrem [lindex $a 2]          #chanrem [lindex $a 2]
561          # Call all the part binds:          # Call all the part binds:
562          foreach b [binds part] {          foreach b [binds part] {
# Line 571  proc ::tcldrop::irc::PART {from key arg} Line 568  proc ::tcldrop::irc::PART {from key arg}
568                          }                          }
569                  }                  }
570          }          }
571            variable ChannelNicks
572            set element [string tolower "$channel,$nick"]
573            array unset ChannelNicks $element
574            if {[array get ChannelNicks [string tolower *,$nick]] == {}} {
575                    variable Nicks
576                    array unset Nicks [string tolower $nick]
577            }
578  }  }
579    
580  # Process the results from NOTICE $channel:  # Process the results from NOTICE $channel:
 # Proc by Papillon@EFNet  
581  bind raw - NOTICE ::tcldrop::irc::NOTICE 99  bind raw - NOTICE ::tcldrop::irc::NOTICE 99
582  proc ::tcldrop::irc::NOTICE {from key arg} {  proc ::tcldrop::irc::NOTICE {from key arg} {
583          set larg [split $arg]          set larg [split $arg]
# Line 649  proc ::tcldrop::irc::PRIVMSGx {from key Line 652  proc ::tcldrop::irc::PRIVMSGx {from key
652  # FixMe: This proc is untested, once verified that it works it'll be safe to remove the original one (above).  # FixMe: This proc is untested, once verified that it works it'll be safe to remove the original one (above).
653  proc ::tcldrop::irc::PRIVMSG {from key arg} {  proc ::tcldrop::irc::PRIVMSG {from key arg} {
654          # FixMe: Need a command that finds the users handle.          # FixMe: Need a command that finds the users handle.
         # set handle [finduser $from]  
         set handle {*}  
655          set nick [lindex [set from [split $from !]] 0]          set nick [lindex [set from [split $from !]] 0]
656          set uhost [lindex $from end]          set uhost [lindex $from end]
657            set handle [finduser $uhost]
658          set larg [split $arg]          set larg [split $arg]
659          set dest [lindex $larg 0]          set dest [lindex $larg 0]
660          puts "$handle $nick $uhost $larg $dest"          puts "$handle $nick $uhost $larg $dest"
# Line 669  proc ::tcldrop::irc::PRIVMSG {from key a Line 671  proc ::tcldrop::irc::PRIVMSG {from key a
671                  #       putlog "CTCP PING From: $nick"                  #       putlog "CTCP PING From: $nick"
672                  #       putserv "NOTICE $nick :\001PING $text\001"                  #       putserv "NOTICE $nick :\001PING $text\001"
673                  #}                  #}
674                  #if {[string compare "VERSION\001" $key]==0]} {                  #if {[string compare "VERSION\001" $key]==0} {
675                  #       # might want to change this versionreply ;) --- Papillon                  #       # might want to change this versionreply ;) --- Papillon
676                  #       putserv "NOTICE $nick :\001VERSION Tcldrop v$::shortver by FireEgl\001"                  #       putserv "NOTICE $nick :\001VERSION Tcldrop v$::shortver by FireEgl\001"
677                  #}                  #}
# Line 686  proc ::tcldrop::irc::PRIVMSG {from key a Line 688  proc ::tcldrop::irc::PRIVMSG {from key a
688                          }                          }
689                  } else {                  } else {
690                          # All PUB binds are called:                          # All PUB binds are called:
691                            variable ChannelNicks
692                            set element [string tolower $dest,$nick]
693                            array set nickinfo $ChannelNicks($element)
694                            array set nickinfo [list idle [clock seconds]]
695                            set ChannelNicks($element) [array get nickinfo]
696                          if {![::tcldrop::irc::callpub $nick $uhost $handle $dest $command $args]} {                          if {![::tcldrop::irc::callpub $nick $uhost $handle $dest $command $args]} {
697                                  # If callpub returned 0, do the PUBM binds:                                  # If callpub returned 0, do the PUBM binds:
698                                  ::tcldrop::irc::callpubm $nick $uhost $handle $dest $text                                  ::tcldrop::irc::callpubm $nick $uhost $handle $dest $text
# Line 694  proc ::tcldrop::irc::PRIVMSG {from key a Line 701  proc ::tcldrop::irc::PRIVMSG {from key a
701          }          }
702  }  }
703    
704    #  ischanban <ban> <channel>
705    #    Returns: 1 if the specified ban is on the given channel's ban list
706    #      (not the bot's banlist for the channel)
707    #    Module: irc
708    proc ::tcldrop::irc::ischanban {ban channel} {
709            variable Bans
710            set element [string tolower $channel,$ban]
711            if {[array get Bans $element] == {}} {
712                    return 0
713            } else {
714                    return 1
715            }
716    }
717    
718    #  ischanexempt <exempt> <channel>
719    #    Returns: 1 if the specified exempt is on the given channel's exempt
720    #      list (not the bot's exemptlist for the channel)
721    #    Module: irc
722    proc ::tcldrop::irc::ischanexempt {exempt channel} {
723    }
724    
725    #  ischaninvite <invite> <channel>
726    #    Returns: 1 if the specified invite is on the given channel's invite
727    #      list (not the bot's invitelist for the channel)
728    #    Module: irc
729    proc ::tcldrop::irc::ischaninvite {invite channel} {
730    }
731    
732    #  chanbans <channel>
733    #    Returns: a list of the current bans on the channel. Each element is
734    #      a sublist of the form {<ban> <bywho> <age>}. age is seconds from the
735    #      bot's POV.
736    #    Module: irc
737    proc ::tcldrop::irc::chanbans {channel} {
738            variable Bans
739            set element [string tolower $channel]
740            variable ChannelNicks
741            array set botarray $ChannelNicks([string tolower $channel,$::botnick])
742            foreach el [array names Bans $element,*] {
743                    array set banlist $Bans($el)
744                    set age [expr [clock seconds] - $botarray(join)]
745                    lappend thelist [list $banlist(ban) $banlist(creator) $age]
746            }
747            return $thelist
748    }
749    
750    #  chanexempts <channel>
751    #    Returns: a list of the current exempts on the channel. Each element is
752    #      a sublist of the form {<exempts> <bywho> <age>}. age is seconds from the
753    #      bot's POV.
754    #    Module: irc
755    proc ::tcldrop::irc::chanexempts {channel} {
756    }
757    
758    #  chaninvites <channel>
759    #    Returns: a list of the current invites on the channel. Each element is
760    #      a sublist of the form {<invites> <bywho> <age>}. age is seconds from the
761    #      bot's POV.
762    #    Module: irc
763    proc ::tcldrop::irc::chaninvites {channel} {
764    }
765    
766    #  resetbans <channel>
767    #    Description: removes all bans on the channel that aren't in the bot's
768    #      ban list and refreshes any bans that should be on the channel but
769    #      aren't
770    #    Returns: nothing
771    #    Module: irc
772    proc ::tcldrop::irc::resetbans {channel} {
773            variable Bans
774    }
775    
776    #  resetexempts <channel>
777    #    Description: removes all exempt on the channel that aren't in the bot's
778    #      exempt list and refreshes any exempts that should be on the channel
779    #      but aren't
780    #    Returns: nothing
781    #    Module: irc
782    proc ::tcldrop::irc::resetexempts {channel} {
783    }
784    
785    #  resetinvites <channel>
786    #    Description: removes all invites on the channel that aren't in the bot's
787    #      invite list and refreshes any invites that should be on the channel
788    #      but aren't
789    #    Returns: nothing
790    #    Module: irc
791    proc ::tcldrop::irc::resetinvites {channel} {
792    }
793    
794    
795  #  onchan <nickname> [channel]  #  onchan <nickname> [channel]
796  #    Returns: 1 if someone by that nickname is on the specified channel (or  #    Returns: 1 if someone by that nickname is on the specified channel (or
797  #      any channel if none is specified); 0 otherwise  #      any channel if none is specified); 0 otherwise
# Line 802  proc ::tcldrop::irc::getchanhost {nick { Line 900  proc ::tcldrop::irc::getchanhost {nick {
900    
901  #  getchanjoin <nickname> <channel>  #  getchanjoin <nickname> <channel>
902  #    Returns: timestamp (unixtime format) of when the specified nickname  #    Returns: timestamp (unixtime format) of when the specified nickname
903  #      joined the channel  #      joined the channel; 0 if the specified user isn't on the channel
904  proc ::tcldrop::irc::getchanjoin {nick channel} {  proc ::tcldrop::irc::getchanjoin {nick channel} {
905            if {![botonchan $channel] || ![onchan $nick $channel]} { return 0 }
906          variable ChannelNicks          variable ChannelNicks
907            set element [string tolower $channel,$nick]
908            array set nickinfo $ChannelNicks($element)
909            return "$nickinfo(join)"
910  }  }
911    
912  #  onchansplit <nick> [channel]  #  onchansplit <nick> [channel]
# Line 842  proc ::tcldrop::irc::chanlist {channel { Line 944  proc ::tcldrop::irc::chanlist {channel {
944  #    Returns: number of minutes that person has been idle; 0 if the  #    Returns: number of minutes that person has been idle; 0 if the
945  #      specified user isn't on the channel  #      specified user isn't on the channel
946  proc ::tcldrop::irc::getchanidle {nick channel} {  proc ::tcldrop::irc::getchanidle {nick channel} {
947            if {![botonchan $channel] || ![onchan $nick $channel]} { return 0 }
948            variable ChannelNicks
949            set element [string tolower $channel,$nick]
950            array set nickinfo $ChannelNicks($element)
951            set min [string trimleft [clock format [expr [clock seconds] - $nickinfo(idle)] -format %M] 0]
952            if {$min == {}} { set min 0 }
953            return $min
954  }  }
955    
956  #  getchanmode <channel>  #  getchanmode <channel>
957  #    Returns: string of the type "+ntik key" for the channel specified  #    Returns: string of the type "+ntik key" for the channel specified
 # Proc by Papillon@EFNet  
958  proc ::tcldrop::irc::getchanmode {channel} {  proc ::tcldrop::irc::getchanmode {channel} {
959          if {![botonchan $channel]} { return }          if {![botonchan $channel]} { return }
960          variable Channels          variable Channels

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

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