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.

auto tempshun

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
L
LB_1981
Voice
Posts: 15
Joined: Mon Jun 08, 2009 5:53 am

auto tempshun

Post by LB_1981 »

Can any one help modify this i want it to auto tempshun users that have been added also if poss it will need something like botnick addtempshun nickname so i dont have to go into shells to add nicks

Code: Select all

set akillnicks { 
  "nick1" 
  "nick2" 
  "nick3" 
  "etc." 
} 

bind raw - NOTICE client:connect 

proc client:connect {from keyword args} { 
  global akillnicks 
  if {[string match "*Client connecting on port*" $args]} { 
    set usernick [lindex [split $args] 9] 
    foreach nick $akillnicks { 
      if {[string equal -nocase $nick $usernick]} { 
        # your akill thing here 
        break 
      } 
    } 
  } 
} 
iv slightly changed it myself

Code: Select all

set tempnicks { 
"nickt" 
} 

bind raw - NOTICE client:connect 

proc client:connect {from keyword args} { 
global tempshunnicks 
if {[string match "*Client connecting on port*" $args]} { 
set usernick [lindex [split $args] 9] 
foreach nick $tempshunnicks { 
if {[string equal -nocase $nick $usernick]} { 
putserv "TEMPSHUN $nick :Auto Tempshun undesirable user detected"
} 
} 
} 
} 
LB_1981
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

I see the efforts by Sir_Fz (in your previous thread) in trying to dissuade you from using the word 'args' in this manner fell on deaf ears.
I must have had nothing to do
L
LB_1981
Voice
Posts: 15
Joined: Mon Jun 08, 2009 5:53 am

Post by LB_1981 »

i picked this up from the forum didnt write it myself
LB_1981
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

# Shun fun v1.0 by speechles
# egghelp.org version... yay!
# if you like this script donate to slennox :P

## SETTINGS BEGIN

# change this to where the file should be created
# which will keep a backup of the contents kept in
# memory, so you can rehash, restart, die
# and everything stored will be loaded back into
# memory.
# ---
variable shunned "shunlist.txt"

# what should be sent to the server when a user
# is detected within your shunned list?
# %nick will be replaced with the nickname of the
# shunned user.
# ---
variable akillcommand "TEMPSHUN %nick :Auto Tempshun undesirable user detected"

# what channel should new shun additions/removals
# be echoed to? change this to "" if you dont want
# to echo to a channel.
# ---
variable shunechochan "#cwstats"

# -------------------------------------------------------------------
# keep in mind ONLY masters/owners may add, remove or list the
# shunned nicks. change the binds below from mn|mn to what you
# wish them to be if this doesn't float your boat. It also works via
# private message with the bot, and bot replies in notices.
# !addshun !delshun !listshun are your commands available.
# -------------------------------------------------------------------

## SCRIPT BEGINS

# does our memory backup file exist?
if {![file exists $shunned]} {
  # no create a blank one to start with
  set shunfile [open $shunned w]
  # blank our memory to match
  set akilllist [list]
  close $shunfile
} else {
  # yes, open the backup and read it into memory
  set shunfile [open $shunned r]
  set akilllist [split [read $shunfile] "\n"] 
  close $shunfile
}

# binds
bind raw - NOTICE client:connect
bind msg mn|mn !addshun client:shun
bind msg mn|mn !delshun client:deshun
bind msg mn|mn !listshun client:listshun

# connecting users
proc client:connect {from keyword text} {
  # is the message the one we want?
  if {[string match -nocase "*Client connecting on port*" $text]} {
    # acquire the nickname
    set usernick [string tolower [lindex [split $text] 9]]
    # is this nickname to be akilled?
    if {[lsearch -exact $::akilllist $usernick] != -1} {
      # yes, correct the placeholder in akillcommand
      regsub "%nick" $::akillcommand $usernick akill
      # issue the akill
      putserv "$akill"
      if {[string length $::shunechochan]} {
        putserv "privmsg $::shunechochan :$usernick has been autotempshunned - undesirable user detected."
      }
    }
  }
}

# add shun
proc client:shun {nick uhost hand text} {
  if {![string length [set shun [string tolower [lindex [split $text] 0]]]]} {
    putserv "notice $nick :Please supply a nickname to shun."
    return
  }
  # append nickname to backup file
  set shunfile [open $::shunned a]
  puts $shunfile $shun
  close $shunfile
  # add the nickname to memory
  lappend ::akilllist $shun
  # report success
  putserv "notice $nick :$shun was successfully added."
  if {[string length $::shunechochan]} {
    putserv "privmsg $::shunechochan :$nick has added $shun to the shun list."
  }
}

# remove shun
proc client:deshun {nick uhost hand text} {
  if {![string length [set shun [string tolower [lindex [split $text] 0]]]]} {
    putserv "notice $nick :Please supply a nickname to unshun."
    return
  }
  # is the nick even in memory?
  if {[set pos [lsearch -exact $::akilllist $shun]] != -1} {
    # yes, remove it from memory
    set ::akilllist [lreplace $::akilllist $pos $pos]
    # write new backup file
    open shunfile [open $::shunned w]
    foreach nick $::akilllist {
      puts $shunfile $nick
    }
    close $shunfile
    # report success
    putserv "notice $nick :$shun was successfully removed."
    if {[string length $::shunechochan]} {
      putserv "privmsg $::shunechochan :$nick has removed $shun from the shun list."
    }
  } else {
    # no, the nickname isn't in our list.
    putserv "notice $nick :$shun is not in the list. Use !listshun to see the list."
    if {[string length $::shunechochan]} {
      putserv "privmsg $::shunechochan :$nick attempted to remove $shun from the shun list but $shun is not in the shun list. "
    }
  }
}

# list shun
proc client:listshun {nick uhost hand text} {
  # build a header for our list response.
  putserv "notice $nick :Shunlist is as follows:"
  # recurse through the nicknames 10 per line and spam them.
  for {set n 0} {$n<[expr {[llength $::akilllist] +1}]} {incr n 10} {
    putserv "notice $nick :[join [lrange $::akilllist $n [expr {$n + 9}]] ", "]"
  }
}
Untested, written in notepad... might be slight syntax or other errors, this should get you going in the right direction.. Enjoy the comments as well, knowing how it works helps understanding... :wink:

Edit: Corrected all remaining issues, enjoy the script... ;)
Last edited by speechles on Fri Jun 19, 2009 7:07 pm, edited 12 times in total.
L
LB_1981
Voice
Posts: 15
Joined: Mon Jun 08, 2009 5:53 am

Post by LB_1981 »

Many thanks for your reply and help the nicks are being added to the list but are not being tempshunned on connect i just need it to tempshun not akill
LB_1981
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

LB_1981 wrote:Many thanks for your reply and help the nicks are being added to the list but are not being tempshunned on connect i just need it to tempshun not akill
That is because I messed up on the regsub, which changes the %nick in your akillcommand line into the correct nickname. I've corrected it in the script above so using it now will work and tempshun that user.

Don't mistake the word "akillist" to mean it's going to akill them. This is merely a variable name. The action taken will be the command you put into akillcommand. As you notice, the exact command you gave is what is presently there. ;)
L
LB_1981
Voice
Posts: 15
Joined: Mon Jun 08, 2009 5:53 am

Post by LB_1981 »

speechles wrote:
LB_1981 wrote:Many thanks for your reply and help the nicks are being added to the list but are not being tempshunned on connect i just need it to tempshun not akill
That is because I messed up on the regsub, which changes the %nick in your akillcommand line into the correct nickname. I've corrected it in the script above so using it now will work and tempshun that user.

Don't mistake the word "akillist" to mean it's going to akill them. This is merely a variable name. The action taken will be the command you put into akillcommand. As you notice, the exact command you gave is what is presently there. ;)

im getting this error on the bots partyline when a user connects

_-9:35am-_ <ChanGuardian> [03:35] Tcl error [client:connect]: can't read "::akilllist": no such variable
LB_1981
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

LB_1981 wrote:im getting this error on the bots partyline when a user connects

_-9:35am-_ <ChanGuardian> [03:35] Tcl error [client:connect]: can't read "::akilllist": no such variable
Doh... Corrected that mistake in the script above.. Try it again ;)
L
LB_1981
Voice
Posts: 15
Joined: Mon Jun 08, 2009 5:53 am

Post by LB_1981 »

Only other problem im getting is when i rehash the bot this happens

_-11:13am-_ <ChanGuardian> [05:13] Tcl error in file 'eggdrop.conf':
_-11:13am-_ <ChanGuardian> [05:13] can not find channel named "shunlist.txt"
_-11:13am-_ <ChanGuardian> while executing
_-11:13am-_ <ChanGuardian> "read $shunned"
_-11:13am-_ <ChanGuardian> invoked from within
_-11:13am-_ <ChanGuardian> "if {![file exists $shunned]} {
_-11:13am-_ <ChanGuardian> # no create a blank one to start with
_-11:13am-_ <ChanGuardian> set shunfile [open $shunned w]
_-11:13am-_ <ChanGuardian> # blank our memory to match
_-11:13am-_ <ChanGuardian> set akilll..."
_-11:13am-_ <ChanGuardian> (file "scripts/autoshun.tcl" line 31)
_-11:13am-_ <ChanGuardian> invoked from within
_-11:13am-_ <ChanGuardian> "source scripts/autoshun.tcl"
_-11:13am-_ <ChanGuardian> (file "eggdrop.conf" line 1365)
_-11:13am-_ <ChanGuardian> [05:13] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)

I have to delete the shunlist.txt then restart the bot for it to work
get this also when a user disconnects from server
_-11:27am-_ <ChanGuardian> [05:27] Tcl error [client:connect]: invoked "break" outside of a loop
also when the user disconnects they seem to be removed from the shunlist so when they rejoin the server they dont get shunned apart from that all is ok

also if possible could the bot message #cwstats nick has been autotempshun undesirable user detected
LB_1981
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

LB_1981 wrote:Only other problem im getting is when i rehash the bot this happens

_-11:13am-_ <ChanGuardian> [05:13] Tcl error in file 'eggdrop.conf':
_-11:13am-_ <ChanGuardian> [05:13] can not find channel named "shunlist.txt"
_-11:13am-_ <ChanGuardian> while executing
_-11:13am-_ <ChanGuardian> "read $shunned"
_-11:13am-_ <ChanGuardian> invoked from within
_-11:13am-_ <ChanGuardian> "if {![file exists $shunned]} {
_-11:13am-_ <ChanGuardian> # no create a blank one to start with
_-11:13am-_ <ChanGuardian> set shunfile [open $shunned w]
_-11:13am-_ <ChanGuardian> # blank our memory to match
_-11:13am-_ <ChanGuardian> set akilll..."
_-11:13am-_ <ChanGuardian> (file "scripts/autoshun.tcl" line 31)
_-11:13am-_ <ChanGuardian> invoked from within
_-11:13am-_ <ChanGuardian> "source scripts/autoshun.tcl"
_-11:13am-_ <ChanGuardian> (file "eggdrop.conf" line 1365)
_-11:13am-_ <ChanGuardian> [05:13] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)

I have to delete the shunlist.txt then restart the bot for it to work
get this also when a user disconnects from server
_-11:27am-_ <ChanGuardian> [05:27] Tcl error [client:connect]: invoked "break" outside of a loop
also when the user disconnects they seem to be removed from the shunlist so when they rejoin the server they dont get shunned apart from that all is ok

also if possible could the bot message #cwstats nick has been autotempshun undesirable user detected
Yep, there were some lingering issues remaining to be corrected. After all this was written entirely in notepad with no testing on my behalf what so ever so this was bound to happen. Also added your echo messages to a channel. The bot will echo all autotempshuns, additions, and removals to your echo channel. This should be the final changes and everything should work as promised. Thanks for testing it, now enjoy it working.. heh ;)
L
LB_1981
Voice
Posts: 15
Joined: Mon Jun 08, 2009 5:53 am

Post by LB_1981 »

Thanks speechless that works a treat now
LB_1981
L
LB_1981
Voice
Posts: 15
Joined: Mon Jun 08, 2009 5:53 am

Post by LB_1981 »

Sorry to bother again my bot has global flags but its only doing the tempshun to ppl that join the server its on is their anyway for it to beable to tempshun users than join on either server
irc.chattersworld.co.uk - leaf.chattersworld.co.uk
LB_1981
Post Reply