View previous topic :: View next topic |
Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 859
|
Posted: Thu Sep 24, 2020 1:06 am Post subject: |
|
|
tnx crazycat gettin this output:
Quote: |
(@TCL-Tester) : Can't find spamlist for #opers
|
|
|
Back to top |
|
 |
CrazyCat Owner

Joined: 13 Jan 2002 Posts: 973 Location: France
|
Posted: Thu Sep 24, 2020 5:27 am Post subject: |
|
|
You can try with the following code:
Code: | bind PUB - * pub:spam
bind CTCP - ACTION ctcp:spam
bind PART - * part:spam
bind SIGN - * sign:spam
array set spamlist {}
proc pub:spam {nick uhost hand chan txt} {
add:spam $nick [string tolower $chan]
}
proc ctcp:spam {nick uhost hand chan key txt} {
add:spam $nick [string tolower $chan]
}
proc add:spam {nick chan} {
if {[info exists ::spamlist($chan)]} {
putserv "PRIVMSG $chan :spamlist exists for $chan"
set pos [lsearch -nocase [dict keys [join $::spamlist($chan)]] $nick]
if {$pos >= 0} {
putserv "PRIVMSG $chan :$nick was in, removing"
set ::spamlist($chan) [lreplace $::spamlist($chan) $pos $pos]
}
}
lappend ::spamlist($chan) [list $nick [clock seconds]]
putserv "PRIVMSG $chan :adding/updating $nick in $chan"
}
proc part:spam {nick uhost hand chan {txt ""}} {
ban:spam $nick $uhost [string tolower $chan]
}
proc sign:spam {nick uhost hand chan txt} {
ban:spam $nick $uhost [string tolower $chan]
}
proc ban:spam {nick uhost chan} {
if {![info exists ::spamlist($chan)]} {
putserv "PRIVMSG $chan :Can't find spamlist for $chan"
return
}
set pos [lsearch -nocase [dict keys [join $::spamlist($chan)]] $nick]
if {$pos > -1} {
scan [lindex $::spamlist($chan) $pos] {%s%s} user time
set now [clock seconds]
if {[expr $now - $time] < 6} {
set ::spamlist($chan) [lreplace $::spamlist($chan) $pos $pos]
set mask [maskhost "$nick!$uhost" 3]
pushmode $chan +b $mask
} else {
putserv "PRIVMSG $chan :More than 5s, doing nothing"
}
} else {
putserv "PRIVMSG $chan :Can't find $nick in spamlist of $chan"
}
} |
I added a add:spam proc which is used to avoid multiple entries for a same nick in the spamlist _________________ https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3740 Location: Mint Factory
|
Posted: Thu Sep 24, 2020 9:55 am Post subject: |
|
|
Good catch on that string tolower $chan as this could have caused some issues.
Like I previously mentioned, should consider adding a nick change function and something for a bit of house keeping just in case something doesn't work as should and you end up with a big array stored in memory with a bunch of gunk.
One thing I don't understand why did you complicated the add:spam, meaning if the pos is above -1 (meaning it exists in the list) then unless you need to update the data there's no need to remove and then add it at the end. Here's something simplified:
Code: |
proc add:spam {nick chan} {
set match 0
if {[info exists ::spamlist($chan)]} {
putserv "PRIVMSG $chan :spamlist exists for $chan"
set pos [lsearch -nocase [dict keys [join $::spamlist($chan)]] $nick]
if {$pos > -1} {
putserv "PRIVMSG $chan :$nick was found in the list, skipping.."
incr match
}
}
if {!$match} {
putserv "PRIVMSG $chan :$nick wasn't in, adding.."
lappend ::spamlist($chan) [list $nick [clock seconds]]
}
}
|
So, swe first check if the spamlist array has records for #channel, then check if nick is found in them. If found we increment match, else will remain at default 0 value. At the end if match is 0 (meaning we don't have any records for nick) we add him in the list. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
Back to top |
|
 |
CrazyCat Owner

Joined: 13 Jan 2002 Posts: 973 Location: France
|
Posted: Thu Sep 24, 2020 10:16 am Post subject: |
|
|
I complicated the procedure to force the update of the last speaking action time for $nick on $chan and not skipping it.
Little example :
Code: | [16:00:00] --> spammer as joined #test
[16:00:01] * spammer says hello to all
[16:00:05] <spammer> go on http://omg.spamming.net
[16:00:07] <-- spammer has quit (http://omg.spamming.net) |
If you skip already existing user in spamlist, you'll have the 16:00:01 record, it won't ban when spammer quits at 16:00:07.
Your simplified version works only for spammers which don't speak until they "speak & quit". Mine will ban anyone which exit less than 6 seconds after he had spoke (this is how I understand the mirc script).
BTW, I think this script is a bad idea, polite pple as me will be banned:
Code: | [16:59:57] <CrazyCat> Time to go, cya pple !
[16:59:59] <-- CrazyCat has quit (Cya) |
_________________ https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 859
|
Posted: Thu Sep 24, 2020 11:27 am Post subject: |
|
|
thank you tried your last post got the same result:
|
|
Back to top |
|
 |
CrazyCat Owner

Joined: 13 Jan 2002 Posts: 973 Location: France
|
Posted: Thu Sep 24, 2020 1:44 pm Post subject: |
|
|
looks like add:spam is never called.
Modify the two first proc:
Code: | proc pub:spam {nick uhost hand chan txt} {
putserv "PRIVMSG $chan :get pub from $nick"
add:spam $nick [string tolower $chan]
putserv "PRIVMSG $chan :stored pub from $nick"
}
proc ctcp:spam {nick uhost hand chan key txt} {
putserv "PRIVMSG $chan :get act from $nick"
add:spam $nick [string tolower $chan]
putserv "PRIVMSG $chan :stored act from $nick"
} |
I think you have now enough debug examples to make yours own tests & debug. _________________ https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 859
|
Posted: Thu Sep 24, 2020 2:23 pm Post subject: |
|
|
seems to work proper now thanx CrazyCat and caesar much apreciated |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3740 Location: Mint Factory
|
Posted: Fri Sep 25, 2020 2:58 am Post subject: |
|
|
@CrazyCat Ah, I see, in that case just replace it instead of removing and adding it again:
Code: |
proc add:spam {nick chan} {
global spamlist
set match 0
set now [clock seconds]
if {[info exists spamlist($chan)]} {
putserv "PRIVMSG $chan :spamlist exists for $chan"
set pos [lsearch -nocase [dict keys [join $spamlist($chan)]] $nick]
if {$pos > -1} {
scan [lindex $spamlist($chan) $pos] {%s%s} user time
putserv "PRIVMSG $chan :$nick was found in the list, updating the seconds from $time to $now .."
set spamlist($chan) [lreplace $spamlist($chan) $pos $pos [list $user $now]]
incr match
}
}
if {!$match} {
putserv "PRIVMSG $chan :$nick wasn't in, adding.."
lappend spamlist($chan) [list $nick $now]
}
}
|
You can use the same lreplace line on the nick change function where you will have $newnick (or what variable you want to use) instead of $user  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 859
|
Posted: Sat Sep 26, 2020 3:53 am Post subject: |
|
|
I think having to avoiding checking wether nick has changed perhaps its better to use *! *@host:channel to store and use that way it wont matter if they change nick |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3740 Location: Mint Factory
|
Posted: Sat Sep 26, 2020 5:46 am Post subject: |
|
|
What if there are two distinct people with same host?  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 859
|
Posted: Sat Sep 26, 2020 12:04 pm Post subject: |
|
|
We allow 1 nick per IP on this network caesar
Last edited by simo on Sun Sep 27, 2020 4:31 pm; edited 1 time in total |
|
Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 859
|
Posted: Sat Sep 26, 2020 3:29 pm Post subject: |
|
|
could this be modified to have it check for host instead of nick so we dont have to worry about changed nicks or adding another proc for nick ? |
|
Back to top |
|
 |
|