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.

newchanban within a timer.

Old posts that have not been replied to for several years.
Locked
U
Unknown1
Voice
Posts: 11
Joined: Fri Jun 11, 2004 5:40 pm

newchanban within a timer.

Post by Unknown1 »

Code: Select all

bind pubm - "$EngNickChangeWrkChan !nickchange*" EngNickChange:pubm:EngNickChangeTrig

proc EngNickChange:pubm:EngNickChangeTrig {nick uhost hand chan args} {
	global EngNickChangeMsgBan EngNickChangeBanTime
	set name [string range $args 13 end-1]
	if { [isop $nick] || [ishalfop $nick] || [isvoice $nick] } {
              if { [onchan $name $chan ] } {
			if { [isop $name $chan] || [ishalfop $name $chan] || [isvoice $name $chan] || [string match "FreshIRC.com" $uhost] } {
				puthelp "PRIVMSG $chan :ACTION $name likes his name as it is.."
				return 0
			}
			puthelp "PRIVMSG $chan :ACTION $name, You have one minute to change your name to a more appropriate name. Use /nick newname to change it."
 			set test "newchanban $chan $name NCTrig \"$EngNickChangeMsgBan\" $EngNickChangeBanTime none"
			timer 1 $test
			return 0
		}
		puthelp "PRIVMSG $chan :ACTION I don't see $name"
	}
}

bind pubm - "$EngNickChangeWrkChan *" EngNickChange:pubm:EngNickChange

proc EngNickChange:pubm:EngNickChange {nick uhost hand chan args} {
	global EngNickChangeWarn EngNickChangeMsgWarn EngNickChangeMsgKick EngNickChangeMsgBan EngNickChangeBanTime
	if {[string tolower [string range $nick 0 7]] == "emuleirc" || [string tolower [string range $nick 0 4]] == "fresh"} {
		if {([info exists EngNickChangeWarn($uhost)] == 1)} {
			if {$EngNickChangeWarn($uhost) == 1} {
	  			putserv "KICK $chan $nick : $EngNickChangeMsgKick"
  				incr EngNickChangeWarn($uhost)
			} elseif {$EngNickChangeWarn($uhost) == 2} {
				newchanban $chan $nick NCAuto $EngNickChangeMsgBan $EngNickChangeBanTime none
			}
		} else {
			puthelp "PRIVMSG $chan :ACTION $nick $EngNickChangeMsgWarn"
			set EngNickChangeWarn($uhost) 1
			timer 60 "unset $EngNickChangeWarn($uhost)"
		}
	}
}
Two questions here... This is a code segment I created..

First: In the first proc, I use the "args" var.. Is it normal for the args string to look like "{!nickchange name}".. I didn't notice the "{}" in other procs I did..

Second: When I do the newchanban in the second proc, it adds the ban and instantly removes that user.. But when I do it in a timer, it adds the ban, but doesn't enfoced it until the user leaves and returns to the channel? How can I get it to enfoce the ban instantly?
U
Unknown1
Voice
Posts: 11
Joined: Fri Jun 11, 2004 5:40 pm

Post by Unknown1 »

OK.. Update..

Yes, I have +enforcebans on those channels..

But I also have +dynamicbans on those channels..

So, I must make them bans sticky for +enforcebans to work..

Isn't this a bug??????


It shouldn't matter if it's a sticky or not for +enforcebans to work...
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

You can use any variable, usually people use
args, arg or text... that doesn't really affect much.

Secondly... this is the wrong way to use newchanban
set test "newchanban $chan $name NCTrig \"$EngNickChangeMsgBan\" $EngNickChangeBanTime none"
timer 1 $test
Using those extra \ and " (slashes and quotation marks) is quite messy.
See this:
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.
It would be something like:
newchanban $chan $name NCTrig $EngNickChangeMsgBan $EngNickChangeBanTime
However, if you want to delay the ban for a with a timer or utimer
then you can make it call to a delayed procedure.

Instead of this:

Code: Select all

set test "newchanban $chan $name NCTrig \"$EngNickChangeMsgBan\" $EngNickChangeBanTime none" 
timer 1 $test 
Use this:

Code: Select all

proc EngNickChange:pubm:EngNickChangeTrig {nick uhost hand chan args} { 
global EngNickChangeMsgBan EngNickChangeBanTime 
.............
.............
timer 1 [list EngNickChangeNewChanBan $chan $name $EngNickChangeMsgBan $EngNickChangeBanTime]
 return 0 
 } 
 puthelp "PRIVMSG $chan :ACTION I don't see $name" 
 } 
} 

proc EngNickChangeNewChanBan {chan name EngNickChangeMsgBan EngNickChangeBanTime} {
newchanban $chan $name NCTrig $EngNickChangeMsgBan $EngNickChangeBanTime
return 1
}
Plus I would suggest if you would use smaller variable names as they are messy the longer they get and keep them in lowercase if possible as well.

For the enforcebans, basically you can use:
channel set $chan +enforcebans
#This will enable enforce bans on a channel.

channel set $chan -enforcebans
#This will disable enforce bans on a channel.
If you want to use enforce bans, with the newchanban for
a delayed timer, I suggest you use this:

Code: Select all

proc EngNickChange:pubm:EngNickChangeTrig {nick uhost hand chan args} { 
global EngNickChangeMsgBan EngNickChangeBanTime 
.............
.............
utimer 55 "channel set $chan +enforcebans"
timer 1 [list EngNickChangeNewChanBan $chan $name $EngNickChangeMsgBan $EngNickChangeBanTime]
utimer 65 "channel set $chan -enforcebans"
 return 0 
 } 
 puthelp "PRIVMSG $chan :ACTION I don't see $name" 
 } 
} 

proc EngNickChangeNewChanBan {chan name EngNickChangeMsgBan EngNickChangeBanTime} {
newchanban $chan $name NCTrig $EngNickChangeMsgBan $EngNickChangeBanTime
}
#This would enable enforcebans on the channel just before the
bot would add the newchanban, and when its done, enforcebans
would be disabled, randomly set it to 5 secs in between your timer
for 1 minute.

You should read the sample .conf file what basically the enforcebans
does and what does the dynamicbans does and clear your concept.

enforcebans
When a ban is set, kick people who are on the channel and match
the ban?

dynamicbans
Only activate bans on the channel when necessary? This keeps
the channel's ban list from getting excessively long. The bot
still remembers every ban, but it only activates a ban on the
channel when it sees someone join who matches that ban.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

awyeah wrote:You can use any variable, usually people use
args, arg or text... that doesn't really affect much.
Not true... $args has special meaning in Tcl... I recommend staying away from using this variable name, unless you know what you are doing and want it's behaviour.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Could be... however I've seen alot of scripts
using args and.. infact I think i've used them with
most of my scripts.. I haven't really seen a difference
however.

Maybe there is... maybe you just need to find it out, heh.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
d
dollar
Op
Posts: 178
Joined: Tue Oct 28, 2003 3:47 pm
Location: Netherlands

Post by dollar »

awyeah wrote:Could be... however I've seen alot of scripts
using args and.. infact I think i've used them with
most of my scripts.. I haven't really seen a difference
however.

Maybe there is... maybe you just need to find it out, heh.
Well I'll get my old example out again, "you can open a door by using the correct key, or by driving over it with your car". Why use the wrong way if you can use the good way and be less prone to errors?
dollar (or something similar) at:
#eggdrop / #tcl - undernet
#egghelp / #tcl / #eggtcl - efnet
#eggdrop.support / #tcl - quakenet
#eggdrop - ircnet
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

For example...

If you have two procs declared as such:

Code: Select all

proc one_myproc {args} {
  putlog "$args"
}

proc two_myproc {vars} {
  putlog "$vars"
}
You may call one_myproc like such:

Code: Select all

one_myproc arg1 arg2 arg3 arg4 arg5
But.. if you call two_myproc the same:

Code: Select all

two_myproc arg1 arg2 arg3 arg4 arg5
You will get an error stating that you have called two_myproc with too many arguments...

$args can be thought of as a list, no matter what...
Locked