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 

Want to add ban to this working script (thx demond)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
mikey2
Voice


Joined: 18 Aug 2005
Posts: 19

PostPosted: Fri Aug 19, 2005 5:53 pm    Post subject: Want to add ban to this working script (thx demond) Reply with quote

This bit of code to check if a user's nick is registered works great (a big thanks go out to Demond for all their help:)

Code:

bind join - * foo
proc foo {n u h c} {
   puthelp "whois $n"
}
bind raw - 311 got311 ;# first WHOIS reply
bind raw - 307 got307 ;# nick has identified (registered)
bind raw - 318 got318 ;# End of /WHOIS list
proc got311 {f k t} {
   set n [lindex [split $t] 1]
   set ::whoised($n) 0
}
proc got307 {f k t} {
   set n [lindex [split $t] 1]
   incr ::whoised($n)
}
proc got318 {f k t} {
   set n [lindex [split $t] 1]
   if {$::whoised($n) == 0} {
      puthelp "privmsg $n :please identify or register your nick"
   }
}

Now, I would like to add a ban to this which would kick/ban a non-reg. user for 5 mins upon joining my channel. After 3 attempts to join channel with a non-reg. nick the user gets banned permanently.

Thanks for all your support. This website rocks.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Aug 19, 2005 7:35 pm    Post subject: Reply with quote

Code:
# ban after how many joins in how many seconds?
set banafter(j:s) 3:60

bind join - * kick:unreg

foreach {banafter(j) banafter(s)} [split $banafter(j:s) :] {break}

proc kick:unreg {nick uhost hand chan} {
 global banafter whoised rejoins
 if {![info exists rejoins([set n [string tolower $nick]])]} { set rejoins($n) 0 }
 if {!$whoised($nick)} {
  puthelp "kick $chan $nick :please identify or register your nick"
  utimer $banafter(s) [list incr rejoins($n) -1]
  if {[incr rejoins($n)] >= $banafter(j)} {
   puthelp "MODE $chan +b *!*@[lindex [split $uhost @] 1]"
  }
 }
}

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts


Last edited by Sir_Fz on Fri Aug 19, 2005 7:36 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Fri Aug 19, 2005 7:36 pm    Post subject: Reply with quote

You could replace the 'puthelp' line in got318 with 'newchanban'

Quote:
newchanban <channel> <ban> <creator> <comment> [lifetime] [options]
Description: adds a ban to the ban list of a channel; creator is given
credit for the ban in the ban list. lifetime is specified in
minutes. If lifetime is not specified, ban-time (usually 60) is
used. Setting the lifetime to 0 makes it a permanent ban.

_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
mikey2
Voice


Joined: 18 Aug 2005
Posts: 19

PostPosted: Fri Aug 19, 2005 8:05 pm    Post subject: Reply with quote

Thanks for your quick comments Sir_Fz. And Alchera, can you give me an example of your suggestion? Sorry I'm a newbie here.

Question for Sir_Fz:

Will this code kick/ban for 5 mins. for each join? As this will prevent auto-join for non-reg. users. So the flow should be as follows:

1st. join - kick/ban (5 min. ban)
2nd. join - kick/ban (5 min. ban)
3rd. join - kick/ban (permanent ban)

I like how you set so I can adjust the j/s (join/sec.).

Thanks for your help.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Aug 19, 2005 8:45 pm    Post subject: Reply with quote

No, the code I gave will kick the first 2 times, and ban on the third join. If you want it to ban for 5 minutes on each join, then add
Code:
newchanban $chan *!*@[lindex [split $uhost @] 1] unreg "please identify or register your nick" 5

instead of the kick command.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
mikey2
Voice


Joined: 18 Aug 2005
Posts: 19

PostPosted: Fri Aug 19, 2005 9:04 pm    Post subject: Reply with quote

Sorry for being such a bonehead, but can you include this in your code, and paste the whole script here so I can see how it's done?

Thanks.
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Sat Aug 20, 2005 12:23 am    Post subject: Reply with quote

mikey2 wrote:
Sorry for being such a bonehead, but can you include this in your code, and paste the whole script here so I can see how it's done?

Thanks.

Simply replace:
Code:
puthelp "kick $chan $nick :please identify or register your nick"

with:
Code:
newchanban $chan *!*@[lindex [split $uhost @] 1] unreg "please identify or register your nick" 5

_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
mikey2
Voice


Joined: 18 Aug 2005
Posts: 19

PostPosted: Sat Aug 20, 2005 2:31 pm    Post subject: Reply with quote

thanks for all your help... I'll give it a try.
Back to top
View user's profile Send private message
mikey2
Voice


Joined: 18 Aug 2005
Posts: 19

PostPosted: Sat Aug 20, 2005 3:07 pm    Post subject: Reply with quote

Script works, but only if you do a /hop in the channel. It does not ban when the user initially joins the channel. That's what I would like it to do. Here's the code:
Code:

bind join - * foo
proc foo {n u h c} {
   puthelp "whois $n"
}
bind raw - 311 got311 ;# first WHOIS reply
bind raw - 307 got307 ;# nick has identified (registered)
bind raw - 318 got318 ;# End of /WHOIS list
proc got311 {f k t} {
   set n [lindex [split $t] 1]
   set ::whoised($n) 0
}
proc got307 {f k t} {
   set n [lindex [split $t] 1]
   incr ::whoised($n)
}
proc got318 {f k t} {
   set n [lindex [split $t] 1]
   if {$::whoised($n) == 0} {
      puthelp "privmsg $n :Hello $n and welcome.  You MUST register your nick to join this channel."
   }
}
# ban after how many joins in how many seconds?
set banafter(j:s) 3:60

bind join - * kick:unreg

foreach {banafter(j) banafter(s)} [split $banafter(j:s) :] {break}

proc kick:unreg {nick uhost hand chan} {
 global banafter whoised rejoins
 if {![info exists rejoins([set n [string tolower $nick]])]} { set rejoins($n) 0 }
 if {!$whoised($nick)} {
  newchanban $chan *!*@[lindex [split $uhost @] 1] unreg "please identify or register your nick. 5 min. ban.  Please return after you have registered." 5
  utimer $banafter(s) [list incr rejoins($n) -1]
  if {[incr rejoins($n)] >= $banafter(j)} {
   puthelp "MODE $chan +b *!*@[lindex [split $uhost @] 1]"
  }
 }
}


Any ideas??? I appreciate your help.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Aug 20, 2005 5:26 pm    Post subject: Reply with quote

Try this:
Code:
bind join - * foo
bind raw - 311 got311 ;# first WHOIS reply
bind raw - 307 got307 ;# nick has identified (registered)
bind raw - 318 got318 ;# End of /WHOIS list

proc foo {n u h c} {
 global whoisc
 puthelp "whois $n"
 set whoisc($n) "$c *!*@[lindex [split $uhost @] 1]"
}

proc got311 {f k t} {
 set n [lindex [split $t] 1]
 set ::whoised($n) 0
}

proc got307 {f k t} {
 set n [lindex [split $t] 1]
 incr ::whoised($n)
}

proc got318 {f k t} {
 global whoisc
 set n [lindex [split $t] 1]
 if {$::whoised($n) == 0} {
  puthelp "privmsg $n :Hello $n and welcome.  You MUST register your nick to join this channel."
  if {[info exists whoisc($n)]} {
   newchanban [lindex [split $whoisc($n)] 0] [lindex [split $whoisc($n)] 1] unreg "please identify or register your nick. 5 min. ban.  Please return after you have registered." 5
  }
 }
}

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
mikey2
Voice


Joined: 18 Aug 2005
Posts: 19

PostPosted: Sat Aug 20, 2005 7:01 pm    Post subject: Reply with quote

oops...this one doesn't ban at all. gives pm to user, but no ban onjoin nor with multiple /hops. Notice you cut out this portion of code:
Code:

 utimer $banafter(s) [list incr rejoins($n) -1]
  if {[incr rejoins($n)] >= $banafter(j)} {
   puthelp "MODE $chan +b *!*@[lindex [split $uhost @] 1]"

is this required? maybe this is the prob.

Also, I noticed this script is reversing the bans that had already been set in channel from other ops.

Thanks for your help.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun Aug 21, 2005 10:17 pm    Post subject: Reply with quote

Try to add
Code:
putkick [lindex [split $whoisc($n)] 0] $n "please identify or register your nick. 5 min. ban.  Please return after you have registered."

after the newchanban line and see if it kicks the user out.

PS: don't double post.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
b|_ack
Voice


Joined: 10 Feb 2005
Posts: 6

PostPosted: Thu Aug 25, 2005 12:14 pm    Post subject: Reply with quote

Sir_Fz wrote:
Try to add
Code:
putkick [lindex [split $whoisc($n)] 0] $n "please identify or register your nick. 5 min. ban.  Please return after you have registered."

after the newchanban line and see if it kicks the user out.

PS: don't double post.
Can someone please let me know how I can just ban any/all unregistered nicks which have the word {bot b0t serv sevr} Thnx
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Thu Aug 25, 2005 12:30 pm    Post subject: Reply with quote

b|_ack wrote:
Sir_Fz wrote:
Try to add
Code:
putkick [lindex [split $whoisc($n)] 0] $n "please identify or register your nick. 5 min. ban.  Please return after you have registered."

after the newchanban line and see if it kicks the user out.

PS: don't double post.
Can someone please let me know how I can just ban any/all unregistered nicks which have the word {bot b0t serv sevr} Thnx


by using the above script after patching it to check if the nick contains whatever sh*tword you deemed unacceptable
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive 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