208 |
bind time - {* * * * *} ::tcldrop::irc::JoinChannels |
bind time - {* * * * *} ::tcldrop::irc::JoinChannels |
209 |
proc ::tcldrop::irc::JoinChannels {args} { |
proc ::tcldrop::irc::JoinChannels {args} { |
210 |
foreach channel [channels] { |
foreach channel [channels] { |
211 |
if {[channel get $channel inactive]} { |
if {[channel get $channel inactive] && [botonchan $channel]} { |
212 |
if {[botonchan $channel]} { |
putloglev d $channel "Joined +inactive channel $channel ...Leaving!" |
213 |
putloglev d $channel "Joined +inactive channel $channel ...Leaving!" |
lappend partchannels $channel |
|
lappend partchannels $channel |
|
|
} |
|
214 |
} elseif {![botonchan $channel]} { |
} elseif {![botonchan $channel]} { |
215 |
lappend joinchannels $channel |
lappend joinchannels $channel |
216 |
} elseif {![botisop $channel]} { |
} elseif {![botisop $channel]} { |
222 |
if {[info exists partchannels]} { puthelp "PART [join $partchannels ,]" } |
if {[info exists partchannels]} { puthelp "PART [join $partchannels ,]" } |
223 |
} |
} |
224 |
|
|
225 |
# Proc by Papillon@EFNet |
# FixMe: Add support for server modes. |
226 |
# FixMe: Untested. |
# FixMe: Add support for personal modes. (maybe) |
|
# (Papillon) -> I do not know what you want to share with the pushmode, but here is a little something to get you started. |
|
227 |
bind raw - MODE ::tcldrop::irc::MODE 99 |
bind raw - MODE ::tcldrop::irc::MODE 99 |
228 |
proc ::tcldrop::irc::MODE {from key arg} { |
proc ::tcldrop::irc::MODE {from key arg} { |
229 |
# Note, it should share some code with the pushmode command I think.. |
putlog "MODE from: $from" |
230 |
|
putlog "MODE key: $key" |
231 |
|
putlog "MODE arg: $arg" |
232 |
set nick [lindex [set from [split $from !]] 0] |
set nick [lindex [set from [split $from !]] 0] |
233 |
set uhost [lindex $from 1] |
set uhost [lindex $from 1] |
234 |
set handle [finduser $uhost] |
set handle [finduser $nick!$uhost] |
235 |
set channel [lindex [set arg [split $arg]] 0] |
set channel [lindex [set arg [split $arg]] 0] |
236 |
set modes [lindex $arg 1] |
set modes [string trimleft [lindex $arg 1] :] |
237 |
for {set a 0} {$a <= [string length $modes]} {incr a} { |
set victims [lrange $arg 2 end] |
238 |
set c [string index $modes $a] |
putlog "MODE nick: $nick" |
239 |
if {$c != {:}} { |
putlog "MODE uhost: $uhost" |
240 |
append splitted "$c " |
putlog "MODE handle: $handle" |
241 |
} |
putlog "MODE channel: $channel" |
242 |
} |
putlog "MODE modes: $modes" |
243 |
set v 2 |
# First we process all the modes.. |
244 |
variable ChannelNicks |
# For example, this takes a mode like: |
245 |
foreach mo [split $splitted] { |
# "+o-o FireEgl FireEgl" |
246 |
if {$mo == {+} || $mo == {-}} { |
# and appends it to the $splitmodes list as: |
247 |
set lastm $mo |
# {-o FireEgl} |
248 |
} elseif {$mo != {}} { |
# (Note the missing +o FireEgl ..since it doesn't actually do anything in the real world it got removed.) |
249 |
set mc "${lastm}$mo" |
set v -1 |
250 |
set victim [lindex $arg $v] |
lappend splitmodes |
251 |
set element [string tolower $channel,$victim] |
foreach m [split $modes {}] { |
252 |
if {[info exists ChannelNicks($element)]} { |
switch -- $m { |
253 |
array set nickinfo $ChannelNicks($element) |
{+} - {-} { set plusminus $m } |
254 |
switch -- $mc { |
{} {} |
255 |
{+o} { array set nickinfo [list op 1] } |
{default} { |
256 |
{-o} { array set nickinfo [list op 0] } |
# This searches $splitmodes to see if there's already a similar mode already saved: |
257 |
{+v} { array set nickinfo [list voice 1] } |
if {[set pos [lsearch $splitmodes ?[set mode "$m [lindex $victims [incr v]]"]]] != -1} { |
258 |
{-v} { array set nickinfo [list voice 0] } |
# A similar mode was found, replace it: |
259 |
{+h} { array set nickinfo [list halfop 1] } |
set splitmodes [lreplace $splitmodes $pos $pos $plusminus$mode] |
260 |
{-h} { array set nickinfo [list halfop 0] } |
} else { |
261 |
|
# No similar mode was found, append to the list: |
262 |
|
lappend splitmodes $plusminus$mode |
263 |
} |
} |
|
set ChannelNicks($element) [array get nickinfo] |
|
264 |
} |
} |
265 |
incr v |
} |
266 |
foreach b [binds mode] { |
} |
267 |
foreach {type flags mask count proc} $b {} |
foreach m $splitmodes { |
268 |
if {[string match -nocase $mask "$channel $mc"]} { |
set mode [string range $m 0 1] |
269 |
::tcldrop::countbind $type $mask $proc |
set victim [string range $m 3 end] |
270 |
if {[catch { $proc $nick $uhost $handle $channel $mc $victim} err]} { |
# This switch discards all the modes that don't make any changes on $channel: |
271 |
putlog "Error in $proc: $err" |
# (Such as a +o on somebody that already had ops) |
272 |
puterrlog "$::errorInfo" |
switch -- $mode { |
273 |
} |
{+o} { if {[isop $victim $channel]} { continue } } |
274 |
|
{-o} { if {![isop $victim $channel]} { continue } } |
275 |
|
{+v} { if {[isvoice $victim $channel]} { continue } } |
276 |
|
{-v} { if {![isvoice $victim $channel]} { continue } } |
277 |
|
{+h} { if {[ishalfop $victim $channel]} { continue } } |
278 |
|
{-h} { if {![ishalfop $victim $channel]} { continue } } |
279 |
|
} |
280 |
|
# If a "continue" wasn't triggered above, |
281 |
|
# we call all of the mode binds with that mode: |
282 |
|
foreach b [binds mode] { |
283 |
|
foreach {type flags mask count proc} $b {} |
284 |
|
if {[string match -nocase $mask "$channel $mode"]} { |
285 |
|
if {[catch { $proc $nick $uhost $handle $channel $mode $victim } err]} { |
286 |
|
putlog "Error in $proc: $err" |
287 |
|
puterrlog "$::errorInfo" |
288 |
} |
} |
289 |
|
::tcldrop::countbind $type $mask $proc |
290 |
} |
} |
291 |
} |
} |
292 |
} |
} |
293 |
} |
} |
294 |
|
|
295 |
|
bind mode - "* ?o" ::tcldrop::irc::mode 0 |
296 |
|
bind mode - "* ?v" ::tcldrop::irc::mode 0 |
297 |
|
bind mode - "* ?h" ::tcldrop::irc::mode 0 |
298 |
|
proc ::tcldrop::irc::mode {nick uhost handle channel mode victim} { |
299 |
|
variable ChannelNicks |
300 |
|
if {[info exists ChannelNicks([set element [string tolower "$channel,$victim"]])]} { |
301 |
|
array set channickinfo $ChannelNicks($element) |
302 |
|
} |
303 |
|
switch -- $mode { |
304 |
|
{+o} { array set channickinfo [list op 1] } |
305 |
|
{-o} { array set channickinfo [list op 0] } |
306 |
|
{+v} { array set channickinfo [list voice 1] } |
307 |
|
{-v} { array set channickinfo [list voice 0] } |
308 |
|
{+h} { array set channickinfo [list halfop 1] } |
309 |
|
{-h} { array set channickinfo [list halfop 0] } |
310 |
|
} |
311 |
|
set ChannelNicks($element) [array get channickinfo] |
312 |
|
} |
313 |
|
|
314 |
|
|
315 |
# irc.choopa.net: 311 FireEgl FireEgl ~FireEgl adsl-17-134-83.bhm.bellsouth.net * Proteus |
# irc.choopa.net: 311 FireEgl FireEgl ~FireEgl adsl-17-134-83.bhm.bellsouth.net * Proteus |
316 |
# Process results from a WHOIS: |
# Process results from a WHOIS: |
373 |
set ident [lindex [split $from !@] 1] |
set ident [lindex [split $from !@] 1] |
374 |
set address [lindex [split $from @] end] |
set address [lindex [split $from @] end] |
375 |
set handle [finduser $from] |
set handle [finduser $from] |
|
#Updating the Nicks/ChannelNicks arrays |
|
376 |
variable ChannelNicks |
variable ChannelNicks |
377 |
array set channickinfo [list nick $nick op 0 voice 0 halfop 0] |
array set channickinfo [list nick $nick op 0 voice 0 halfop 0] |
378 |
set ChannelNicks([string tolower "$channel,$nick"]) [array get channickinfo] |
set ChannelNicks([string tolower "$channel,$nick"]) [array get channickinfo] |
380 |
if {[info exists Nicks([set element [string tolower $nick]])]} { array set nickinfo $Nicks($element) } |
if {[info exists Nicks([set element [string tolower $nick]])]} { array set nickinfo $Nicks($element) } |
381 |
array set nickinfo [list nick $nick handle $handle ident $ident address $address] |
array set nickinfo [list nick $nick handle $handle ident $ident address $address] |
382 |
set Nicks($element) [array get nickinfo] |
set Nicks($element) [array get nickinfo] |
383 |
# Call all the join binds: |
# Call all of the join binds: |
384 |
foreach b [binds join] { |
foreach b [binds join] { |
385 |
foreach {type flags mask count proc} $b {} |
foreach {type flags mask count proc} $b {} |
386 |
if {[string match -nocase $mask "$channel $from"] && [matchattr $handle $flags $channel]} { |
if {[string match -nocase $mask "$channel $from"] && [matchattr $handle $flags $channel]} { |
677 |
} |
} |
678 |
variable ChannelNicks |
variable ChannelNicks |
679 |
array unset ChannelNicks [string tolower "$channel,$nick"] |
array unset ChannelNicks [string tolower "$channel,$nick"] |
680 |
if {![onchan $nick]} { |
variable Nicks |
681 |
variable Nicks |
array unset Nicks [string tolower $nick] |
|
array unset Nicks [string tolower $nick] |
|
|
} |
|
682 |
} |
} |
683 |
|
|
684 |
# Process the results from NOTICE $channel: |
# Process the results from NOTICE $channel: |
773 |
# Module: irc |
# Module: irc |
774 |
proc ::tcldrop::irc::ischanban {ban channel} { |
proc ::tcldrop::irc::ischanban {ban channel} { |
775 |
variable Bans |
variable Bans |
776 |
info exists Bans([string tolower $channel,$ban]) |
info exists Bans([string tolower "$channel,$ban"]) |
777 |
} |
} |
778 |
|
|
779 |
# ischanexempt <exempt> <channel> |
# ischanexempt <exempt> <channel> |
782 |
# Module: irc |
# Module: irc |
783 |
proc ::tcldrop::irc::ischanexempt {exempt channel} { |
proc ::tcldrop::irc::ischanexempt {exempt channel} { |
784 |
variable Exempts |
variable Exempts |
785 |
info exists Exempts([string tolower $channel,$exempt]) |
info exists Exempts([string tolower "$channel,$exempt"]) |
786 |
} |
} |
787 |
|
|
788 |
# ischaninvite <invite> <channel> |
# ischaninvite <invite> <channel> |
799 |
# a sublist of the form {<ban> <bywho> <age>}. age is seconds from the |
# a sublist of the form {<ban> <bywho> <age>}. age is seconds from the |
800 |
# bot's POV. |
# bot's POV. |
801 |
# Module: irc |
# Module: irc |
802 |
proc ::tcldrop::irc::chanbans {channel} { |
proc ::tcldrop::irc::chanbans {channel {banmask {*}}} { |
803 |
set banlist [list] |
set banlist [list] |
804 |
variable Bans |
variable Bans |
805 |
foreach b [array names Bans [string tolower $channel],*] { |
foreach b [array names Bans [string tolower $channel],$banmask] { |
806 |
array set baninfo $Bans($b) |
array set baninfo $Bans($b) |
807 |
lappend banlist [list $baninfo(ban) $baninfo(creator) $baninfo(created)] |
lappend banlist [list $baninfo(ban) $baninfo(creator) $baninfo(created)] |
808 |
} |
} |
815 |
# bot's POV. |
# bot's POV. |
816 |
# Module: irc |
# Module: irc |
817 |
# FixMe: Add support for the age. |
# FixMe: Add support for the age. |
818 |
proc ::tcldrop::irc::chanexempts {channel} { |
proc ::tcldrop::irc::chanexempts {channel {exemptmask {*}}} { |
819 |
set exemptlist [list] |
set exemptlist [list] |
820 |
variable Exempts |
variable Exempts |
821 |
foreach b [array names Exempts [string tolower $channel],*] { |
foreach b [array names Exempts [string tolower $channel],$exemptmask] { |
822 |
array set exemptinfo $Exempts($b) |
array set exemptinfo $Exempts($b) |
823 |
lappend exemptlist [list $exemptinfo(exempt) $exemptinfo(creator) $exemptinfo(created)] |
lappend exemptlist [list $exemptinfo(exempt) $exemptinfo(creator) $exemptinfo(created)] |
824 |
} |
} |
830 |
# a sublist of the form {<invite> <bywho> <age>}. age is seconds from the |
# a sublist of the form {<invite> <bywho> <age>}. age is seconds from the |
831 |
# bot's POV. |
# bot's POV. |
832 |
# Module: irc |
# Module: irc |
833 |
proc ::tcldrop::irc::chaninvites {channel} { |
proc ::tcldrop::irc::chaninvites {channel {invitemask {*}}} { |
834 |
set invitelist [list] |
set invitelist [list] |
835 |
variable Invites |
variable Invites |
836 |
foreach b [array names Invites [string tolower $channel],*] { |
foreach b [array names Invites [string tolower $channel],$invitemask] { |
837 |
array set inviteinfo $Invites($b) |
array set inviteinfo $Invites($b) |
838 |
lappend invitelist [list $inviteinfo(ban) $inviteinfo(creator) $inviteinfo(created)] |
lappend invitelist [list $inviteinfo(ban) $inviteinfo(creator) $inviteinfo(created)] |
839 |
} |
} |
879 |
# any channel if none is specified); 0 otherwise |
# any channel if none is specified); 0 otherwise |
880 |
proc ::tcldrop::irc::onchan {nick {channel {*}}} { |
proc ::tcldrop::irc::onchan {nick {channel {*}}} { |
881 |
variable ChannelNicks |
variable ChannelNicks |
882 |
if {[array names ChannelNicks [string tolower $channel,$nick]] != {}} { |
if {[array names ChannelNicks [string tolower "$channel,$nick"]] != {}} { |
883 |
return 1 |
return 1 |
884 |
} else { |
} else { |
885 |
return 0 |
return 0 |
896 |
# specified, the bot will check all of its channels. If the nick is |
# specified, the bot will check all of its channels. If the nick is |
897 |
# not found, "" is returned. If the nick is found but does not have |
# not found, "" is returned. If the nick is found but does not have |
898 |
# a handle, "*" is returned. |
# a handle, "*" is returned. |
899 |
# |
# Note: Like Eggdrop, Tcldrop ignores $channel. |
|
# channel is ignored, since Tcldrop stores this particular info in a |
|
|
# central place. |
|
900 |
proc ::tcldrop::irc::nick2hand {nick {channel {*}}} { |
proc ::tcldrop::irc::nick2hand {nick {channel {*}}} { |
901 |
variable Nicks |
variable Nicks |
902 |
if {[info exists Nicks([set element [string tolower $nick]])]} { |
if {[info exists Nicks([set element [string tolower $nick]])]} { |
1038 |
set channel [string tolower $channel] |
set channel [string tolower $channel] |
1039 |
if {[info exists PushModes($channel)] && [set pos [lsearch -glob $PushModes($channel) "?[string index $mode 1] $arg"]] != -1} { |
if {[info exists PushModes($channel)] && [set pos [lsearch -glob $PushModes($channel) "?[string index $mode 1] $arg"]] != -1} { |
1040 |
# A conflicting or duplicate mode was found. So we replace it. |
# A conflicting or duplicate mode was found. So we replace it. |
1041 |
lreplace $PushModes($channel) $pos $pos "$mode $arg" |
set PushModes [lreplace $PushModes($channel) $pos $pos "$mode $arg"] |
1042 |
} else { |
} else { |
1043 |
# Otherwise we just lappend to the end: |
# Otherwise we just lappend to the end: |
1044 |
lappend PushModes($channel) "$mode $arg" |
lappend PushModes($channel) "$mode $arg" |