This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

how to modify this script to apply in all channels

Old posts that have not been replied to for several years.
Locked
l
laynuks
Voice
Posts: 35
Joined: Tue May 06, 2003 4:09 pm

how to modify this script to apply in all channels

Post by laynuks »

set thechannel "#channel"
bind kick - * kick:remove

proc kick:remove { nick uhost hand chan targ rsn } {
if {$targ == $::botnick && [string tolower $chan] == [string tolower $::thechannel]} {
putserv "PRIVMSG X :verify $nick"
}
}

bind notc - "* logged in as *" check_verify

proc check_verify {nick host hand arg dest} {
if {[string equal $dest $::botnick]} {
putserv "PRIVMSG X :remuser $::thechannel [lindex [split $arg] end]"
}
}
putlog "Eggdrog remove access if op kicks the bot using /kick #channel kicker"


######

Hi all, in line one of the script

set thechannel "#channel"

this script will only run in specified channel, how do I modify this script so it will run in all channels the bot is in?

I tried setting this

set thechannel "*"

but it did not work,


I also tried

set thechannel "#channel #channel2 #channel3"

but it only recognizes #channel1


Thank You
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

This should be it if I am correct.
I haven't tested it though.

Give it a try and let me know!

Code: Select all

bind kick - * kick:remove 
bind notc - "* logged in as *" check:verify 

proc kick:remove {nick uhost hand chan target reason} {
global botnick
if {($target == $botnick)} {
putserv "PRIVMSG X :verify $nick" 
}
}


proc check:verify {nick host hand arg dest} {
global botnick
if {[string equal $dest $botnick]} { 
foreach i [channels] {
putserv "PRIVMSG X :remuser $i [lindex [split $arg] end]" 
}
} 
} 

#Mind you this might flood your network services, if your bot is
#on alot of channels and it tries to delete alot of access entries.

putlog "Eggdrop remove access if op kicks the bot using /kick #channel kicker" 
You mentioned for the script to work on all channels the bot is on
so it would do this with a loop with for [channels].

You can also convert this script to work on multiple channels the bot is on which you can define, but it would work on only the channels you specify and not on all the channels the bot is on.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

In order to *test* if a chan is in the list you have specified use the lsearch function. Example:
if {[lsearch -exact $mychans $chan] != -1)} {
# got a match! let's do something..
}
Also, you will encount problems when the channel is with upper case or something like this and the there will not be a match. So, either make the test lower case like:
if {[lsearch -exact [string tolower $mychans] [string tolower $chan]] != -1)} {
# got a match! let's do something..
}
or just use something like
if {[string match -nocase "*$chan*" $mychans]} {
# got a match! let's do something..
}
Once the game is over, the king and the pawn go back in the same box.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

caesar wrote: if {[string match -nocase "*$chan*" $mychans]} {
# got a match! let's do something..
}
This will cause problems if for example,
$mychans == "#this #is #my #channel #list"
and
$chan == "#th"
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

This is the code I use for almost all of the tcls
which have multiple channel support.

Code: Select all

#Set the channels on which you would like this script active on
set mychannels "#mychan1 #mychan2 #chan3 #chat4"

if {(([lsearch -exact [split [string tolower $mychannels]] [string tolower $chan]] != -1) || ($mychannels == "*"))} {

This should work if you would want to test this script on
multiple channels and for making it work on all channels
you can use "*".
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
l
laynuks
Voice
Posts: 35
Joined: Tue May 06, 2003 4:09 pm

Post by laynuks »

awyeah wrote:This should be it if I am correct.
I haven't tested it though.

Give it a try and let me know!

Code: Select all

bind kick - * kick:remove 
bind notc - "* logged in as *" check:verify 

proc kick:remove {nick uhost hand chan target reason} {
global botnick
if {($target == $botnick)} {
putserv "PRIVMSG X :verify $nick" 
}
}


proc check:verify {nick host hand arg dest} {
global botnick
if {[string equal $dest $botnick]} { 
foreach i [channels] {
putserv "PRIVMSG X :remuser $i [lindex [split $arg] end]" 
}
} 
} 

#Mind you this might flood your network services, if your bot is
#on alot of channels and it tries to delete alot of access entries.

putlog "Eggdrop remove access if op kicks the bot using /kick #channel kicker" 
You mentioned for the script to work on all channels the bot is on
so it would do this with a loop with for [channels].

You can also convert this script to work on multiple channels the bot is on which you can define, but it would work on only the channels you specify and not on all the channels the bot is on.
<-----

i tried it many times and it seems like it applies to all channels the bot is in, but is seems like the lower command doesnt execute
putserv "PRIVMSG X :remuser $i [lindex [split $arg] end]"


only this command was executed
putserv "PRIVMSG X :verify $nick"



bots console view:
[19:26] AdoBOT kicked from #channel by Eric: AdoBOT
[19:26] #channel: mode change '+o AdoBOT' by X!cservice@undernet.org
[19:27] -X (cservice@undernet.org)- Eric pirch@username.users.undernet.org is logged in as LAYNUKS
[19:27] -X (cservice@undernet.org)- USER: LAYNUKS ACCESS: 499 LU
[19:27] -X (cservice@undernet.org)- CHANNEL: #channel -- AUTOMODE: None
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

strikelight wrote:
caesar wrote: if {[string match -nocase "*$chan*" $mychans]} {
# got a match! let's do something..
}
This will cause problems if for example,
$mychans == "#this #is #my #channel #list"
and
$chan == "#th"
Oups.. indeed. Duno at was I was thinking..

And for kicks via X something like this:

Code: Select all

bind kick - "*" the:x:kick

proc the:x:kick {nick uhost hand chan vict reas} { 
  if {![isbotnick $vict] || $nick != "X"} {
    return
  } 
  set kicker [string trim [lindex [split $reas] 0] {()}] 
  putquick "PRIVMSG X :remuser $chan $kicker"
}
What's the point to add the verify thing when you just want it's access removed?
Once the game is over, the king and the pawn go back in the same box.
l
laynuks
Voice
Posts: 35
Joined: Tue May 06, 2003 4:09 pm

Post by laynuks »

caesar wrote:
bind kick - "*" the:x:kick

proc the:x:kick {nick uhost hand chan vict reas} {
if {![isbotnick $vict] || $nick != "X"} {
return
}
set kicker [string trim [lindex [split $reas] 0] {()}]
putquick "PRIVMSG X :remuser $chan $kicker"
}


What's the point to add the verify thing when you just want it's access removed?

<--- hmmmm

the point of the script is this. If an abusive op kicks the bot using
/kick #channel botnick"

then in order to remuse we need to get the username of the op bye doing
/msg x verify JohnnyOP

then once the username is known remuse the access
/msg x remuser #channel JohnnyOp's_username

Thank You
d
dollar
Op
Posts: 178
Joined: Tue Oct 28, 2003 3:47 pm
Location: Netherlands

Post by dollar »

Please use the CODE tags when pasting code... this way everything gets unreadable... :(
dollar (or something similar) at:
#eggdrop / #tcl - undernet
#egghelp / #tcl / #eggtcl - efnet
#eggdrop.support / #tcl - quakenet
#eggdrop - ircnet
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

I am not aware with Undernet services, however I do know
about ChanServ on DALnet.

You just need to identify your nick with NickServ and if your bot
has a higher access suppose SOp and the person has
AOp then you can remove him from the access list.

If your bot and the person have the same level of access
then he/she will not be removed from the access lists.

I don't think so you would need to loop the VERIFY command
for the services, would cause a flood, plus there is no mention
of channels in it.

If your services require to verify/identify for each channel to
gain access, then you might have too.

***
I haven't changed any variables or string split style, just modified
for it to work on all the channels to bot is in... to my logic it should
work, rest depends upon your networks services and they style they
use to remove users.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked