egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to add multiple channel support in idleop.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
pakistani1
Voice


Joined: 20 Apr 2005
Posts: 26
Location: Pakistan Zindabad

PostPosted: Mon Jun 09, 2008 8:03 am    Post subject: how to add multiple channel support in idleop.tcl Reply with quote

Code:
set idle_interval "6"

set idle_time "5"

set idle_exclude_bots "1"
 
set idle_channels "#channel1 #channel2 #channel3"

bind raw - 317 idlecheck

proc idlecheck {nick int arg} {
  global idle_time idle_channels
   set nick [string tolower [lindex $arg 1]]
   set idle [string tolower [lindex $arg 2]]
   set minutesidle [expr $idle / 60]
   if {$minutesidle > $idle_time && $nick != "^pagli^" && $nick != "Pakistani1" && $nick != "n0mercy" && $nick != "Go|dLeaf" && $nick != "priya007" && $nick != "^ash^" && $nick != "PehReDaaR" && $nick != "pinky^" && $nick != "bilal" && $nick != "huzur" && $nick != "janat" } {
      foreach channel $idle_channels {
         putserv "PRIVMSG Chanserv@services.dal.net :deop $channel $nick"
      putserv "PRIVMSG $channel :deoped  $nick from $channel (too Much Idle)"
      putserv "privmsg $nick :deoped u from $channel (too much idle)"
      }
    }
}

proc perform_whois { } {
  global idle_channels botnick idle_exclude_bots idle_interval
    if {$idle_channels == " "} {
      set idle_temp [channels]
    } else {
    set idle_temp $idle_channels
    }
    foreach chan $idle_temp {
       foreach person [chanlist $chan] {
         if { [isop $person $chan]} {
           if {$idle_exclude_bots == 1} {
             if {(![matchattr [nick2hand $person $chan] b]) && ($person != $botnick) && $person != "topguard" && $person != "pr0b"} { putserv "WHOIS $person $person" }
           }
           if {$idle_exclude_bots == 0} {
              if {$person != $botnick} { putserv "WHOIS $person $person" }
           }
         }
       }
    }
if {![string match "*time_idle*" [timers]]} {
 timer $idle_interval perform_whois
  }
}
if {![string match "*time_idle*" [timers]]} {
 timer $idle_interval perform_whois
  }


the script works fine if only one channel is added in set idle_channels "#channel1"

but when i add multiple channels .. it tries to deop idle nicks on all the channels even if the nick is not in that channel ..

eg if nick1 is oped in #channel1 and the script is turned on in #channel1 #channel2 #channel3
the bot sends
msg chanserv@services.dal.net deop #channel1 nick1
msg chanserv@services.dal.net deop #channel2 nick1
msg chanserv@services.dal.net deop #channel3 nick1

even if nick1 is not on #channel2 and #channel3

can some one please tell me how to fix this ?
_________________
!~!~!~!~!~ ::Long Live The REpubLic ::~!~!~!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Nimos
Halfop


Joined: 20 Apr 2008
Posts: 80

PostPosted: Mon Jun 09, 2008 8:20 am    Post subject: Reply with quote

Code:
foreach channel $idle_channels {
         putserv "PRIVMSG Chanserv@services.dal.net :deop $channel $nick"
      putserv "PRIVMSG $channel :deoped  $nick from $channel (too Much Idle)"
      putserv "privmsg $nick :deoped u from $channel (too much idle)"
      }


thats your problem!

use the "search thing" instead of foreach...sry I dont know the command at the moment Embarassed
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Mon Jun 09, 2008 11:50 am    Post subject: Reply with quote

@Nimos, you are close (we need the foreach, it isn't replaced at all).. but since you can't be correct, why do you even post? To raise your post count?
Code:
if {[lsearch -exact [chanlist $channel] $nick] != -1} {

A simple check like this in the appropriate place is what is needed. This will return a 1 (since nicks cannot repeat) if our nick is in the channel list, or a -1 if it is not. Simply checking that it isn't -1 does it.

@pakistani1, this should fix it. Also allows you to use .chanset #youchan +idletime
Also cleaned up your injection of nicks into the evaluation statements. You can now add/remove nicks without having to 'code' them in.
Code:
#--- begin  config ---#

# how often to check idletime
set idle_interval "6"

# max idletime allowed
set idle_time "5"

# exclude other bots from deop?
set idle_exclude_bots "1"

# nicks exempt from deop
set idle_exempt_nicks "^pagli^ Pakistani1 n0mercy Go|dLeaf priya007 ^ash^ PehReDaaR pinky^ bilal huzur janat"

# nicks exempt from whois
set whois_exempt_nicks "topguard pr0b"

# enter the name of the channel service bot here
set idle_servicebot "Chanserv@services.dal.net"

# enter your idle message given here
set idle_message_chan "deoped %nick from %channel (Too Much Idle!)"
set idle_message_nick "deoped you from %channel (Inactive Op with too much idle)"

#--- end of config ---#

bind raw - 317 idlecheck

setudef flag idlechan

proc idlecheck {nick int arg} {
   global idle_time
   set nick [lindex [split $arg] 1]
   set minutesidle [expr {[lindex [split $arg] 2] / 60}]
   if {($minutesidle > $idle_time) && ([lsearch -nocase -exact [split $::idle_exempt_nicks] $nick] == -1)} {
      foreach channel [channels] {
         if {[lsearch -exact [channel info $channel] +idlechan] != -1} {
            # this fixes the problem with chanserv deop messages
            # given when that nick isn't even in the channel
            if {[lsearch -nocase -exact [chanlist $channel] $nick] != -1} {
               # this allows us to use dynamic messages containing
               # variable references which will be replaced
               set idle_mchan [string map {% $} $::idle_message_chan]
               set idle_mnick [string map {% $} $::idle_message_nick]
               putserv "PRIVMSG $::idle_servicebot :deop $channel $nick"
               putserv "PRIVMSG $channel :$idle_mchan"
               putserv "PRIVMSG $nick :$idle_mnick"
            }
         }
      }
   }
}

proc perform_whois { } {
   global idle_exclude_bots idle_interval
   foreach chan [channels] {
      if {[lsearch -exact [channel info $chan] +idlechan] != -1} {
         foreach person [chanlist $chan] {
            if {[isop $person $chan]} {
               if {$idle_exclude_bots != 0} {
                  if {![matchattr [nick2hand $person $chan] b] && ([lsearch -nocase -exact [split $::whois_exempt_nicks] $person] == -1)} {
                     putserv "WHOIS $person $person"
                  }
               } else {
                  if {![isbotnick $person] && ([lsearch -exact [split $::whois_exempt_nicks] $person] == -1)} { putserv "WHOIS $person $person" }
               }
            }
         }
      }
   }
   if {![string match "*time_idle*" [timers]]} {
      timer $idle_interval perform_whois
   }
}

if {![string match "*time_idle*" [timers]]} {
   timer $idle_interval perform_whois
}


Edit: edited to correct problem noted below, forgot to :: those global variables.. DOH!
Also neated up a ton of stuff.. enjoyz Wink
_________________
speechles' eggdrop tcl archive


Last edited by speechles on Wed Jun 11, 2008 10:29 am; edited 20 times in total
Back to top
View user's profile Send private message
pakistani1
Voice


Joined: 20 Apr 2005
Posts: 26
Location: Pakistan Zindabad

PostPosted: Mon Jun 09, 2008 1:31 pm    Post subject: Reply with quote

thanku for ur help speechles
here is the error that i got after i used the above script

can't read "whois_exempt_nicks": no such variable
_________________
!~!~!~!~!~ ::Long Live The REpubLic ::~!~!~!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Mon Jun 09, 2008 4:49 pm    Post subject: Reply with quote

Try the edited code above, heh. Forgot to globalize those variable calls, in other words used $ instead of $:: ..
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
pakistani1
Voice


Joined: 20 Apr 2005
Posts: 26
Location: Pakistan Zindabad

PostPosted: Thu Jun 12, 2008 1:36 pm    Post subject: Reply with quote

the problem persists .. the bot gives the command to deop the idle nick on all the channels the script is turned on..
plus it is now not ignoring the idle_exempt_nicks it deopes the nicks present in the idle_exempt_nicks nick list ...
_________________
!~!~!~!~!~ ::Long Live The REpubLic ::~!~!~!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber