egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

setting ban on msg followed by quit
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 859

PostPosted: Thu Sep 24, 2020 1:06 am    Post subject: Reply with quote

tnx crazycat gettin this output:

Quote:

(@TCL-Tester) : Can't find spamlist for #opers
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 973
Location: France

PostPosted: Thu Sep 24, 2020 5:27 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3740
Location: Mint Factory

PostPosted: Thu Sep 24, 2020 9:55 am    Post subject: Reply with quote

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
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 973
Location: France

PostPosted: Thu Sep 24, 2020 10:16 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 859

PostPosted: Thu Sep 24, 2020 11:27 am    Post subject: Reply with quote

thank you tried your last post got the same result:

Quote:

17:29:54 (Greene) : testing one two three
17:29:54   Quits :   Greene   uid45646@uid-45646.highgate.irccloud.com (Quits: Left IRC)
17:29:54 (@TCL-Tester) : Can't find spamlist for #opers

17:30:27 (Burk) : testing one two three
17:30:27   Parts :   Burk   Jordon@BHYX1EUA.WGERDG6U.HVE14TFS.IP (Parts:)
17:30:27 (@TCL-Tester) : Can't find spamlist for #opers
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 973
Location: France

PostPosted: Thu Sep 24, 2020 1:44 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 859

PostPosted: Thu Sep 24, 2020 2:23 pm    Post subject: Reply with quote

seems to work proper now thanx CrazyCat and caesar much apreciated
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3740
Location: Mint Factory

PostPosted: Fri Sep 25, 2020 2:58 am    Post subject: Reply with quote

@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 Wink
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 859

PostPosted: Sat Sep 26, 2020 3:53 am    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3740
Location: Mint Factory

PostPosted: Sat Sep 26, 2020 5:46 am    Post subject: Reply with quote

What if there are two distinct people with same host? Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 859

PostPosted: Sat Sep 26, 2020 12:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 859

PostPosted: Sat Sep 26, 2020 3:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber