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.

modification

Help for those learning Tcl or writing their own scripts.
Locked
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

modification

Post by pilouuu »

Please how to replace the dcc by cmd on the chan

expl: !badwords or $badwords the bot say notice
bot notice lists global badwords etc etc ( all cmd)

And instead of kick or kickban -------> 1 bad word to inform (warning!!!) repeat bad word kick et 3 repeat banned 2 mns

thx for help

Code: Select all

#badwords.tcl
#by Elven <elven@elven.de>
# LEGAL DISCLAIMER:
#  THIS SCRIPT IS UNDER THE GPL LICENCE.
#   For more information see the accompanying gpl.txt

####################
# Quick Start:
# .badwords                 - lists global badwords
# .badwords #channel        - lists channel badwords
# .badwords all             - lists all badwords
# .+badword <regexp>        - adds global badword
# .+badword #channel <rx>   - adds channel badword
# .-badword <id>            - removes global badword (see .badwords for id)
# .-badword #channel <id>   - go figure
#
# .chanset #channel +badwords - enable badword protection for this channel

####################
# configuration

set badword(cflag) "m|m"
	#what flags are needed to edit badwords? (global|channel)

set badword(flag) "of|of"
	#users not affected by badword scan
	
set badword(reaction) 1
	# 0 - kick
	# 1 - kickban
	
set badword(banmsg) {
	"Badword."
}
	#reason/comment on ban
	
set badword(bantime) 10
	#ban time in minutes
	
set badword(savefile) "$datapath/badwords"
	#file format:
	# =channelname/-globals
	# ~badword
	# ~badword
	# =anotherchannel
	# ~badword
	# ...	

set badword(quietsave) 1
	#dont log 'Saved on automatic save.'

####################
# code below

setudef flag badwords

bind dcc "-" "+badword" badword:add
bind dcc "-" "-badword" badword:del
bind dcc "-" "badwords" badword:list
bind dcc "-" "badword" badword:list
bind evnt "-" "save" badword:save
bind evnt "-" "loaded" badword:load
bind pubm "-" "*" badword:msg



proc badword:add {h i t} {
	global badword badwords
	set lst [split $t]
	set chn [join [lindex $lst 0]]
	set chn [string tolower $chn]
	if {[llength $lst] == 0} {
		putidx $i "\002Syntax:\002 +badword \[#channel\] <regexp string>"
		putidx $i "  Adds a channel or (if channel is ommited) global badword."
		return 0
	}

	if {[regexp {^#.+$} $chn]} {
		if {![matchattr $h $badword(cflag) $chn]} {
			putidx $i "Only channel masters and above can add channel badwords."
			return 1
		}
		set bword [join [lrange $lst 1 end]]
		if {[string trim $bword] == ""} { putidx $i "Please specify a badword to add." ; return 0 }
		if {![info exists badwords($chn)]} {
			set badwords($chn) [list $bword]
		} {
			lappend badwords($chn) $bword
		}
		putidx $i "Added $bword as $chn channel badword."
	} {
		if {![matchattr $h $badword(cflag)]} {
			putidx $i "Only global masters and above can add global badwords."
			return 1
		}
		set bword [join $lst]
		if {[string trim $lst] == ""} { putidx $i "Please specify a badword to add." ; return 0 }
		set chn "-global"
		lappend badwords($chn) $bword
		putidx $i "Added $bword as global badword."
	}

	return 1
}

proc badword:del {h i t} {
	global badword badwords
	set lst [split $t]
	set chn [join [lindex $lst 0]]
	set chn [string tolower $chn]
	if {[llength $lst] == 0} {
		putidx $i "\002Syntax:\002 -badword \[#channel\] <number>"
		putidx $i "  Removes a channel or (if channel is ommited) global badword. Number specifies the item in .badwords"
		return 0
	}
	
	if {[regexp {^#.+$} $chn]} {
		if {![matchattr $h $badword(cflag) $chn]} {
			putidx $i "Only channel masters and above can delete channel badwords."
			return 1
		}	
		set id [join [lindex $lst 1]]
	} {
		if {![matchattr $h $badword(cflag)]} {
			putidx $i "Only global masters and above can delete global badwords."
			return 1
		}		
		set id [join [lindex $lst 0]]
		set chn "-global"
	}
	set bwo [lindex $badwords($chn) $id]
	if {$bwo == ""} {
		putidx $i "Invalid ID."
		return 1
	}
	
	set badwords($chn) [lreplace $badwords($chn) $id $id]
	if {$chn=="-global"} {
		putidx $i "Removed global badword $bwo."
	} {
		putidx $i "Removed channel badword $bwo on $chn."
	}
	return 1	
}

proc badword:list {h i t} {
	global badword badwords
	set lst [split $t]
	set chn [join [lindex $lst 0]]
	set chn [string tolower $chn]
	if {$chn == ""} {
		if {![matchattr $h $badword(cflag)]} {
			putidx $i "Only global masters and above can list global badwords."
			return 1
		}
		if {[info exists badwords(-global)]} {
			if {[llength $badwords(-global)]==0} {
				putidx $i "No global badwords."
			} {
				putidx $i "Global badwords:"
				set l 0
				foreach x $badwords(-global) {
					putidx $i "$l: $x"
					incr l
				}
				putidx $i "End of list."
			}
			
		} {
			putidx $i "No global badwords."
		}
		return 1
	} elseif {$chn == "all"} {
		if {![matchattr $h $badword(cflag)]} {
			putidx $i "Only global masters and above can list all badwords."
			return 1
		}
		foreach x [array names badwords] {
			if {[llength $badwords($x)]==0} { continue }
			if {$x == "-global"} {
				putidx $i "\002Global\002 Badwords"
			} {
				putidx $i "Badwords for channel \002$x\002"
			}
			set l 0
			foreach y $badwords($x) {
				putidx $i "  $l: $y"
				incr l
			}
		}
		putidx $i "End of list."
		return 1
	} elseif {$chn == "save"} {
		if {![matchattr $h $badword(cflag)]} {
			putidx $i "Only global masters and above can save badwords."
			return 1
		}		
		badword:save "noautosave"
	} elseif {$chn == "load"} {
		if {![matchattr $h $badword(cflag)]} {
			putidx $i "Only global masters and above can load badwords."
			return 1
		}		
		badword:load "noautoloaded"		
	} elseif {[regexp {^#.+$} $chn]} {
		if {![matchattr $h $badword(cflag) $chn]} {
			putidx $i "Only channel masters and above can list channel badwords."
			return 1
		}		
		if {[info exists badwords($chn)]} {
			if {[llength $badwords($chn)]==0} {
				putidx $i "No badwords for channel $chn."
			} {
				putidx $i "$chn badwords:"
				set l 0
				foreach x $badwords($chn) {
					putidx $i "$l: $x"
					incr l
				}
				putidx $i "End of list."
			}
		} {
			putidx $i "No badwords for channel $chn."
		}
		#ist channel badwords
		return 1
	} else {
		putidx $i "\002Syntax:\002 : badwords \[save|load|all|#channel\]"
		return 0
	}
}

proc badword:save {t} {
	global badword badwords	
	set f [open $badword(savefile) w]	
	foreach x [array names badwords] {
		if {[llength $badwords($x)]==0} { continue }
		puts $f "=$x"
		foreach y $badwords($x) {
			puts $f "~$y"
		}
	}
	close $f
	if {$t != "save"} {
		if {!$badword(quietsave)} { putlog "Saved badwords." }
	}
	
}
proc badword:load {t} {
	global badword badwords
	catch { unset badwords }
	set f [open $badword(savefile) r]
	set curr "--"
	while {![eof $f]} {
		set ln [gets $f]
		if {![regexp "^(\[=~\])(.+)$" $ln uun t r]} { continue }
		if {$t == "="} {
			set curr $r
		} {
			if {![info exists badwords($curr)]} {
				set badwords($curr) [list $r]
			} {
				lappend badwords($curr) $r
			}
		}
	}
	close $f
	putlog "Loaded badwords."
}


proc badword:msg {n u h c t} {
	global badwords badword
	set c [string tolower $c]
	set hit 0
	if {![channel get $c badwords]} { return 0 }
	if {[isop $n $c]} { if {[channel get $c dontkickops]} { return 0 } }
	if {[matchattr $h $badword(flag) $c]} { return 0 }
	
	if {[info exists badwords(-global)]} {
		foreach x $badwords(-global) {
			if {[string trim $x] == ""} { continue }
			if {[regexp -nocase $x $t]} { set hit 1 ; break }
		}
	}		
	if {!$hit && [info exists badwords($c)]} {
		foreach x $badwords($c) {
			if {[string trim $x] == ""} { continue }
			if {[regexp -nocase $x $t]} { set hit 1 ; break }
		}
	}		
	if {$hit} {
		if {$badword(reaction) == 1} {
			newchanban $c [maskhost $u] "badwords" [join [lindex $badword(banmsg) [rand [llength $badword(banmsg)]]]] $badword(bantime)
		} {
			putserv "KICK $c $n :$badword(banmsg)"
		}
	}
}

putlog "Badwords by Elven loaded."
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

I told you (or did I?) to use xchannel, it does exactly what you need and I'd bet it does it better
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Really, you need to stop doing that demond
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

Post by pilouuu »

demond wrote:I told you (or did I?) to use xchannel, it does exactly what you need and I'd bet it does it better
the script it good but how activated desactivé directly on chan by !chanset #yourchan +x:repeat for expl


thx
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

MeTroiD wrote:Really, you need to stop doing that demond
what's your problem exactly?

if you had better badwords script, I wouldn't hesitate to recommend yours over mine
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

stef007 wrote:
demond wrote:I told you (or did I?) to use xchannel, it does exactly what you need and I'd bet it does it better
the script it good but how activated desactivé directly on chan by !chanset #yourchan +x:repeat for expl


thx
well, my philosophy is that an eggdrop bot should never be controlled via public commands, mainly for security reasons

therefore, xchannel is controlled (configured, to be precise) via DCC command .chanset only
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

demond wrote:well, my philosophy is that an eggdrop bot should never be controlled via public commands, mainly for security reasons
... and for reasons beyond the control of many users they are unable to enter the command console which is why public commands are preferred.

Some scripts are just totally useless under these circumstances.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Alchera wrote: Some scripts are just totally useless under these circumstances.
right

and they are intended to be that way, at least my scripts; as you know, I firmly believe that almost anyone should be able to fix their DCC, I bothered to elaborate on the subject over and over and over again and I'd do that again - we should educate users how to use eggdrop the way it was meant to be used, not to endorse scripts enabling any lamer out there to run eggdrop without having the slightest clue about its inner workings, or at least the console (note that I'm not denying public commands in general; they have great entertainment value, and they should stay that way - leave control functions to the console)

the only valid excuse for not being able to dcc is when both the user and the bot are behind firewalls not allowing listening ports; however, such situation simply doesn't happen in the vast majority of (legitimate) eggdrop use cases - there is no shell provider who would deny you listening port, and your ISP won't do that either; actually, the only scenario I could see that happening in is when you run eggdrop from hacked account on internal corporate machine, which you shouldn't do anyway

so essentially what I'm saying is that virtually any total inability to use DCC is due to lameness or/and laziness, and I'm not on these forums to encourage either
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
m
mm
Halfop
Posts: 78
Joined: Thu Jul 01, 2004 10:24 pm

Post by mm »

MeTroiD wrote:
Really, you need to stop doing that demond


I think Demond and Sir_Fz ' are the great coders, their scripts are the best and bug free plus vast majority of users need these type of scripts so i think nothing wrong to tell the users to use these scripts. Also both of them are active @ this forum helping users and they know their problems very well so i think it's good to tell the person to use these 2 scripts so they can get the best scripts plus it will save their time as well and if they've any issue they can talk to them here.
MM
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

demond : Well pointed! I got to admit that this stuff got annoyng. You know what I'm talking about.

Thread closed.
Once the game is over, the king and the pawn go back in the same box.
Locked