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.

hello I need a script that will remove access when

Old posts that have not been replied to for several years.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Re:hello I need a script that will remove access when...

Post by Alchera »

I stumbled across this post by accident and it was something I have had need of for ages. I have, however, modified the code for DALnet specific use. Below is what I have done:

# Full name of channel services
set chanserv "CHANSERV@SERVICES.DAL.NET"

## Don't change below this.

bind mode - "* kicked" kick_remove

proc kick_remove {nick uhost hand chan mc victim} {
if {$victim == $::botnick} {
putserv "PRIVMSG $::chanserv :ACC $chan $nick"
}
}

bind notc - "* 1 (AOP)*" check_verify

proc check_verify {nick uhost hand msg {dest ""}} {
global botnick; if {$dest == ""} {set dest $botnick}
if {[string equal $dest $botnick]} {
set offender [lindex [split $msg] 0]
set chan [lindex [split $msg] 2]
set thehand [findhand $offender [getchanhost $offender]]
if {$offender != "" || $thehand != "*"} {
deluser $thehand
}
putquick "PRIVMSG $::chanserv :aop $chan del $offender"
putquick "MODE $chan -o $offender"
putkick $chan $offender "You tit head, you just lost access!"
}
}

bind kick - * kick:remove

proc kick:remove { nick uhost hand chan targ rsn } {
if {$targ == $::botnick} {
putserv "PRIVMSG $::chanserv :ACC $chan $nick"
}
}

# findhand - tries to find a handle

proc findhand {nick host} {
if {[validuser $nick]} {
return $nick
} else {
set thehand [nick2hand $nick]
if {[validuser $thehand]} {
return $thehand
}

set thehand [finduser $host]
return $thehand
}
}

I decided to have the bot check its' user list and remove the offending user if found. The use of DALnet's ACC command is not ideal though. If the nick that is opped has access to services under another nick then the script falls over. Use of the WHY command is preferable but I am unable to get it to work. I think the reason is that ChanServ returns formatted text (bold) when the WHY command is used. Here's an example: -ChanServ- Almozo has SOp access to #ricochet. Reason: Identification to the nickname giovann.

The end nick is the one preferably to remove from ChanServ's AOp list.

Any help with being able to use WHY in preferance to ACC will be greatly appreciated. I've just about given up trying. :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

set chanserv "chanserv@Services.dal.net"
set thechannel "#yourchannel"

bind kick - * kick:remove 
bind notc - "* has AOp access to *" check:verify 

proc kick:remove {nick uhost hand chan targ rsn} { 
  if {$targ == $::botnick} { 
   if {[string match $chan $::thechannel]} {
   putserv "PRIVMSG $::chanserv :why $chan $nick" 
    }  
  } 
}

proc check:verify {nick host hand arg dest} { 
  if {[string equal $dest $::botnick]} { 
    putserv "PRIVMSG $::chanserv :AOp $::thechannel del [lindex [split $arg] end]" 
  } 
}
then add to it the check for handle or whatever u want.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Thanks for that. Very much appreciated. :)

I did, however, have to add a bit of code (from MC_8's Moretools.tcl) to strip the bold from the passed argument. The reason being is that I needed to parse the text and the bold just got in the way. Also, the script needs to work in every channel the bot sits in as I need it for loan bots. I also have to contend with ChanServ added periods at the end of the important stuff too. Here's what I did:

proc check:verify {nick host hand arg {dest ""}} {
set arg [string tolower [strip:bold $arg]]
if {[string equal $dest $::botnick]} {
set offender [lindex [split $arg] 0]
set chan [string trim [lindex [split $arg] 5] .]
set opnick [string trim [lindex [split $arg] end] .]
etc etc }

At this stage all appears to be working properly, Founders & SOp's are ignored, which is what I was after.

Thanks again for your help. This was really frustrating me :D

I'll let you know how the finished 'product' turns out.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

u can use Ppslim's proc to strip all control characters.

Code: Select all

set arg [ctrl:filter $arg]

proc ctrl:filter {str} {
  regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str
  return $str
}
also, I made bind notc - "* has AOp access to *" check:verify
so the check:verify proc will not work unless the user has AOp access.

but its a good thing that u have stripped the "." from the channel and the nick.
set chan [string trim [lindex [split $arg] 5] .]
set opnick [string trim [lindex [split $arg] end] .]
I knew its gonna be a prob :P
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Once again, thank you very much for the help. :)

It took me sometime to realise that the script was unable to parse the returned message from ChanServ because of the formatting. Not getting errors made it more frustrating for me as I knew that bind of yours was working, just the rest wasn't. I'm not an experienced TCL scripter btw, and I literally stumbled across the procedure for removing characters from a string. Playing around with C years ago sort of paid off in that area. LOL

Here's what I now have:

# Full name of channel services
set chanserv "chanserv@Services.dal.net"

# Channel *not* to function in
set nogo "#channelname"

bind kick - * kick:remove
bind notc - "* has AOp access to *" check:verify

proc kick:remove {nick uhost hand chan targ rsn} {
if {$targ == $::botnick} {
if {![string match $chan $::nogo]} {
putserv "PRIVMSG $::chanserv :why $chan $nick"
}
}
}

proc check:verify {nick host hand arg {dest ""}} {
set arg [ctrl:filter $arg]
if {[string equal $dest $::botnick]} {
set offender [lindex [split $arg] 0]
set chan [string trim [lindex [split $arg] 5] .]
set opnick [string trim [lindex [split $arg] end] .]
set thehand [findhand $offender [getchanhost $offender]]
if {$offender != "" && $thehand != "*"} {
deluser $thehand
}
putquick "PRIVMSG $::chanserv :aop $chan del $opnick"
putquick "MODE $chan -o $offender"
putkick $chan $offender "You tit head, you just lost access!"
}
}

# ctrl:filter <string>
# Strip all control characters. Thanks to Ppslim. :)

proc ctrl:filter {str} {
regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str
return $str
}

# findhand - tries to find a handle

proc findhand {nick host} {
if {[validuser $nick]} {
return $nick
} else {
set thehand [nick2hand $nick]
if {[validuser $thehand]} {
return $thehand
}

set thehand [finduser $host]
return $thehand
}
}

### End ###

putlog "TCL \002loaded\002: Kick Remove."

End note: Having just tested this I now have the same problem as before. set arg [ctrl:filter $arg] stops all functionality! I'll revert back to the other subroutine.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Ceased to function completely

Post by Alchera »

Problem: having reverted back to my original method of stripping the bold chars, not one piece of the code works! There is no rhyme or reason to this rubbish and it's what I have been contending with off and on for days. The only method that never fails is the ACC trigger. This script was working 100% yesterday and today it doesn't. I have tested it with a windrop and an eggdrop with the exact same stupid results.. it just stops! What makes it more annoying is that the bot *is* receiving the correct response from ChanServ using 'why'. The bold characters are the problem.

Any way of getting this fool proof will be great. I have just about had enough and am ready to give this method away permanently.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You should see this topic.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

this should make it work:

Code: Select all

# Full name of channel services 
set chanserv "chanserv@Services.dal.net" 

# Channel *not* to function in 
set nogo "#channelname" 

bind kick - * kick:remove 
bind notc - "* has AOp access to *" check:verify 

proc kick:remove {nick uhost hand chan targ rsn} { 
if {$targ == $::botnick} { 
if {![string match $chan $::nogo]} { 
putserv "PRIVMSG $::chanserv :why $chan $nick" 
} 
} 
} 

proc check:verify {nick host hand arg {dest ""}} { 
regexp -all {\002} $arg
if {[string equal $dest $::botnick]} { 
set offender [lindex [split $arg] 0] 
set chan [string trim [lindex [split $arg] 5] .] 
set opnick [string trim [lindex [split $arg] end] .] 
set thehand [findhand $offender [getchanhost $offender]] 
if {$offender != "" && $thehand != "*"} { 
deluser $thehand 
} 
putquick "PRIVMSG $::chanserv :aop $chan del $opnick" 
putquick "MODE $chan -o $offender" 
putkick $chan $offender "You tit head, you just lost access!" 
} 
} 

# findhand - tries to find a handle 

proc findhand {nick host} { 
if {[validuser $nick]} { 
return $nick 
} else { 
set thehand [nick2hand $nick] 
if {[validuser $thehand]} { 
return $thehand 
} 
set thehand [finduser $host] 
return $thehand 
} 
} 

### End ### 

putlog "TCL \002loaded\002: Kick Remove."
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Thank you very much again Sir_Fz, and thanks to caesar also, I will try it again and see if it I get more than 24hrs use out of it (now that's the confusing bit). Someone suggested I e-mail DALnet and ask that they remove their stupid formatting but, as they never respond to e-mails I'd be wastng my time. LOL

My frustration has been somewhat enhanced by an inability to concentrate fully due to virul bronchitis but, as someone once said, "S..t happens!" :D

PS: I'm well overdue for new reading glasses too. :o
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

I got it working.. finally!

Post by Alchera »

Hi,

A bit more patience, a bit more reading, a little re-working and I have what I wanted still working after 4 days.....

bind notc - "*Identification to the nickname *" check:verify

proc check:verify {nick host hand arg {dest ""}} {
set msg [ctrl:filter $arg]
if {[string equal $dest $::botnick]} {
# Parse ChanServ's message.
set offender [lindex [split $msg] 0]
set aop [string tolower [lindex [split $msg] 2]]
set chan [string trim [lindex [split $msg] 5] .]
set opnick [string trim [lindex [split $msg] end] .]
# Only an AOp can be punished.
if {![string match $aop "aop"]} {return}
# Delete access, remove op & kick with appropriate message.
putquick "PRIVMSG $::chanserv :aop $chan del $opnick"
putquick "MODE $chan -o $offender"
puthelp "notice $offender :You tit head, you just lost access!"

# Check and see if the offender is in the bots' user list
# If so, delete them!
set thehand [findhand $offender [getchanhost $offender]]

if {$offender != "" && $thehand != "*"} {
deluser $thehand
putcmdlog "Deleted !$offender! from the user database."
save
}
}
}

The bind is the major difference. It's not looking for any formatted text. The "AOp" part of the bind is returned in bold and caused the bot to totally ignore it in previous efforts. I also reverted back to Ppslim's proc for removing formatting and added a conditional statement to determine that the offender is indeed an aop and not a sop. Founder's are ignored as the why command returns a different message. Except for the above, the script is as it was and works perfectly.

Many thanks for all the help, very much appreciated :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

well done :) I didn't realize that the AOp was not being stripped off control characters. nice notice.
l
laynuks
Voice
Posts: 35
Joined: Tue May 06, 2003 4:09 pm

Post by laynuks »

Sir_Fz wrote:man, u said u want it to work when someone does /mode #channel kick botname.
anyway add this code to make the bot work on /kick #channel botname.

Code: Select all

bind kick - * kick:remove

proc kick:remove { nick uhost hand chan targ rsn } {
  if {$targ == $::botnick} {
   putserv "PRIVMSG X :verify $nick"
   }
}
note:do not remove Papillon's code, leave it and add this one into it.

Hi again Sir Finz

this script
......

bind kick - * kick:remove

proc kick:remove { nick uhost hand chan targ rsn } {
if {$targ == $::botnick} {
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]"
}
}
.......
I tried the script but for some reason it did not work still....
so when i did /kick #channel BotName it did not do anything
.....



I tried the first block of the script to test if it works like
note: to test the script I changed verify to kick

bind kick - * kick:remove
proc kick:remove { nick uhost hand chan targ rsn } {
if {$targ == $::botnick} {
putserv "PRIVMSG X :kick $nick"
}
}


I loaded this script but it did not kick me then I did
/kick #channel BotName

Maybe the reason the whole script did not work because the first block dont work to feed to the 2nd block of the script.

Thank You

Laynuks
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

how do you expect it to kick you if you already kicked the bot out of the channel ?

when you test use putlog "Script is working" for example (so it shows this message in partyline if you kicked the bot"

would you paste the notice from X when you msg it verify $nick ?

P.S.: my nick is pronounced "Sir - aF Zee" Sir-Fz :P
l
laynuks
Voice
Posts: 35
Joined: Tue May 06, 2003 4:09 pm

Post by laynuks »

bind kick - * kick:remove
proc kick:remove { nick uhost hand chan targ rsn } {
if {$targ == $::botnick} {
putserv "PRIVMSG X :kick $nick"
}
}


Hello Sir_Fz, i thought this script once loaded to my bot, and if any channel op kicks the bot using /kick #channel BotName then the bot script will execute the line putserv "PRIVMSG X :kick $nick" and kick the op right? sorry for the confusion


"when you test use putlog "Script is working" for example (so it shows this message in partyline if you kicked the bot" would you paste the notice from X when you msg it verify $nick ? <--hmmm I used telnet to connect to the eggdrop and i dont see any message from X, i guess i am missing some options or switch so I will be able to see message from X to the bot.

Thank You
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

laynuks wrote:bot script will execute the line putserv "PRIVMSG X :kick $nick" and kick the op right?
X will do the kicking, not the bot (:P), and it needs to know what channel you want to kick the person from (/msg X KICK <#channel> <nick> <reason>)
Locked