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.

Help with a script

Old posts that have not been replied to for several years.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Help with a script

Post by Sir_Fz »

I want the bot to ban the host of the user who parts with reason : #name of the channel>
like for example:
. . Parts Nick(~xcavz@xxx.xxx.xxx.x) from #channel : (#channel)
. . Chanmode : Bot sets mode +b *!*@xxx.xxx.xxx.x
but i want it to only do that ban if the user joins and parts within 7 seconds.
like this:
[01:00]. . joins nick(~xcavz@xxx.xxx.xxx.x) #channel
[01:00] . . parts nick(~xcavz@xxx.xxx.xxx.x) from #channel : (#channel)
[01:00] . . Chanmode : Bot sets mode +b *!*@xxx.xxx.xxx.x
but if the user stays in the channel for more than 7secs before parting with reason #<channel's name> then the bot doesn't ban.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

use a part bind and getchanjoin. (doc/tcl-commands.doc for details)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

kay, but would the getchanjoin read within a particular interval of time ?
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Sir_Fz wrote:kay, but would the getchanjoin read within a particular interval of time ?
What do you mean? If you'd read tcl-commands.doc you'd know what getchanjoin does...just compare the time returned with the current time minus 7 seconds and you know if you should ban or not.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

getchanjoin <nickname> <channel>
Returns: timestamp (unixtime format) of when the specified nickname
joined the channel
Module: irc
how do I use it ? and explain more to me how the time is measured plz.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Sir_Fz wrote:
getchanjoin <nickname> <channel>
Returns: timestamp (unixtime format) of when the specified nickname
joined the channel
Module: irc
how do I use it ? and explain more to me how the time is measured plz.
Use getchanjoin in the proc triggered by the part bind to find out when the person parting joined... if that time >= (current time - 7) ban the user.

'unixtime' is the number of seconds since 00:00:00 01/01/1970
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

what it would be like ??
if {[getchanjoin * $chan] >= -7} {.... ??
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Sir_Fz wrote:what it would be like ??
if {[getchanjoin * $chan] >= -7} {.... ??
No. Not unless your current time is 23:59:53 12/31/1969 and the nick of your parter is '*'. :P

Fetch the current time in seconds since 1970 using 'clock seconds' or 'unixtime'.

Here's some code to get you started:

Code: Select all

bind part - "#test *" partchk
proc partchk {n u h c a} {
	# was the part reason == the channel name?
	if {[string eq -nocase $c $a]} {
		# did this luser stay for less than 7 seconds?
		if {[getchanjoin $n $c]>=[expr {[clock seconds]-7}]} {
			# yup...ban *!*@[lindex [split $u @] end] or whatever
		}
	}
}
Last edited by user on Tue Jul 22, 2003 5:50 am, edited 1 time in total.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

[snip]
# did this luser stay for more than 7 seconds?
if {[getchanjoin $n $c]>=[expr {[clock seconds]-7}]}
[snip]
this will kick the user if he stays for mor than 7secs or it wil ban the uhost if he parts after he join in these 7secs ?

also if i do bind part - "*!~*@*" <proc-name> then it will check only for users with ~ in their ident ?
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

yes.
yes... although the right syntax would be bind part - "* *~*@*" <procname>
Elen sila lúmenn' omentielvo
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Sir_Fz wrote:
[snip]... for more than 7 ...[/snip]
this will kick the user if he stays for mor than 7secs or it wil ban the uhost if he parts after he join in these 7secs ?
Sorry about adding misleading comments :P (I meant "for LESS than 7 seconds").
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

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

Post by Sir_Fz »

using:

Code: Select all

bind part - "* *~*@*" partchk

proc partchk {nick uhost hand chan rsn} {
if {[string eq -nocase $chan $rsn} {
 if {[getchanjoin $nick $chan] >= [expr {[clock seconds]-4}]} {
  set ban "*!~*@[lindex [split $uhost @] end]"
  newban $ban $::botnick "spammer." 0
  }
 }
}
didn't work, any reasons why ?
Note: the user joined and parted with reason "$chan" within 2 or 3 seconds.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

anybody ? why didn't it work ?
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

If you'd read your error messages you'd know. (missing close bracket in the string eq-line.)
Locked