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.

Need Help , Blacklist tcl

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
a
aboutme
Voice
Posts: 2
Joined: Mon Nov 23, 2015 6:48 am

Need Help , Blacklist tcl

Post by aboutme »

Features: support ip, host, resolve , CIDR

- blacklist file
example: set blacklist(file) "scripts/blacklist.txt"
- special flag
example: only user with flag +B can use commands addban, remban and banlist ( this flag can be settable only from perm owner )

1. Procedures:
- addban
example: partyline command .addban *!*@10.1.1.1 reason time
example CIDR: partyline command: addban *!*@10.1.1.1/8 reason time
- remban
example: partyline command .remban *!*@10.1.1.1
- banlist
example: partyline command: .banlist ( show the current list with all bans )
if is possible to order bans a-z after adding or removing some ban ( but if that load the bot better not )

2. bantype:
- IP: all users join from host/ip will be ban with mask *!*@10.1.1.1 or *!*@some.host.com ( example: use set ipban [maskhost $host 2] )
- HEX: all users join from type: *!*@*.html.chat, *!*@*.xs4all.nl, *!*@*.kiwiirc.com or *!*@*.mibbit.com will be ban with the banmask *!*ident@*.html.chat ( example: use set hexban [maskhost $host 3] )

3. exempt:
- by default eggdrop don't check other eggdrops/bots
- flag I gives user exempt and he wouldn't be checked

4. Putidx
- addban example: putidx $idx "SYNTAX: \003.addban \002<nick>\002!\002<user>\002@\002<host>\002 \[reason\] \[bantime\]\003"
- addban check for existing ban: putidx $idx "[string map {! \002!\002 @ \002@\002} \002$blnick\002] has been \002added\002 to the blacklist."
- remban example: putidx $idx "SYNTAX: \003.remban \002<nick>\002!\002<user>\002@\002<host>\002\003"
- remban message: putidx $idx "[string map {! \002!\002 @ \002@\002} \002$blnick\002] was \002deleted\002 from the blacklist."
- remban check: putidx $idx "[string map {! \002!\002 @ \002@\002} \002$blnick\002] was \002not\002 found in the blacklist."
- banlist example: putidx $idx "SYNTAX: \003.Showing the banlist!\003" , putidx $idx "SYNTAX: \003.End of the banlist!\003"
- ban is added: putidx $idx "[string map {! \002!\002 @ \002@\002} \002$blnick\002] has been \002added\002 to the blacklist.
- ban already exist: putidx $idx "[string map {! \002!\002 @ \002@\002} \002$blnick\002] already \002exists\002 in the blacklist."
- Empty banlist: putidx $idx "There are \002no\002 bans in the blacklist."

5. Handle
- Showing handle of user set the ban ( if is possible to show and date like )
- example reason: (Violation of the rules section 2 of regulation! 13/04/2014 Kiril@Valhalla)

Note:
if user join with host eggdrop resolve host to ip and check in database ( blacklist ).
if blacklist file does not exist than create one!
Check if IP is already added in blacklist!

Legend:
- Time: .addban *!*@10.1.1.1 [censored] ya 60 ( that means ban is for 60 min )
- Time: .addban *!*@10.1.1.1/16 [censored] ya 0 ( that means ban is permanent )

Logic:
user join for example from host [05:20:36] * ShakeIT46982 (d4059ee1@elitsat.html.chat) has joined #gyuvetch
TO DO Procedures:
1. Convert HEX to IP ( d4059ee1 -> 212.5.158.225 )
2. Convert HOST to IP ( Resolve ) if is need it like linux.com -> 140.211.167.50 ( for users join via IRC client not webchat )
3. Compare IP with banlist using matchcidr or whatever is need it!
4. Set Channel ban depends from that is it from *!*@*.html.chat or it is host/ip see 2. bantype

HELP materials:

- hex2ip Procedure:

proc bl:h2d {hex} {
# Simple check to validate proper hex string
if {[regexp {^[a-fA-F0-9]{8}$} $hex]} {
set dec [expr 0x$hex]
set o1 [expr {($dec >> 24) & 0xff}]
set o2 [expr {($dec >> 16) & 0xff}]
set o3 [expr {($dec >> 8) & 0xff}]
set o4 [expr {$dec & 0xff}]

return "$o1.$o2.$o3.$o4"
}
return 0
}

- Checking for perm owner

proc ispermowner {hand} {
global owner
regsub -all -- , [string tolower $owner] "" owners
if {([matchattr $hand n]) && \
([lsearch -exact $owners [string tolower $hand]] != -1)} then {
return 1
}
return 0
}
Post Reply