1

I want Eggdrop to respond to users who have joined the channel in the last 30 minutes. All other users who have been on the channel for more than 30 minutes should be ignored.

set canalativo "#testes"

bind pubm - "*regist*canal*" pub:regchan

proc pub:regchan { nick uhost handle chan arg } {
global canalativo

if {[string match -nocase "$canalativo" $chan]} {

putserv "PRIVMSG $chan :$nick para registar um canal escreve o comando: /ChanServ register #CANAL DESCRICAO-DO-CANAL" } 
 }
Fdcarvalho
  • 57
  • 1
  • 10
  • When are the messages received? When someone joins? – Donal Fellows Feb 26 '20 at 12:56
  • The message is received when someone joins and write the pubm. The command is invoked only when someone writes, the join part is missing. To avoid spam, I want to restrict messages to those who write only in the first 30 minutes after joins. If you’ve been on the channel longer than 30min, eggdrop should ignore it. – Fdcarvalho Feb 26 '20 at 13:12

1 Answers1

0

You could hold an array containing the user and their join time. Something like (untested):

set canalativo "#testes"
array set joinedUsers {}

bind pubm - "*regist*canal*" pub:regchan
bind join - "*!*@*" pub:joinchan

proc pub:regchan { nick uhost handle chan arg } {
    global canalativo joinedUsers

    # Check if - this is the correct channel
    #          - the user is in the array of joined users
    #          - the time the user joined is 1800 seconds ago or less
    if {
        [string match -nocase "$canalativo" $chan] && 
        [info exists joinedUsers($nick)] && 
        [clock seconds]-$joinedUsers($nick) <= 1800
    } {
        putserv "PRIVMSG $chan :$nick para registar um canal escreve o comando: /ChanServ register #CANAL DESCRICAO-DO-CANAL"
    }

    # Remove the user from the array if it is there
    catch {unset joinedUsers($nick)}
}

proc pub:joinchan { nick uhost handle chan } {
    global joinedUsers

    # Add the user and the time they joined to the array
    set joinedUsers($nick) [clock seconds]
}

This is just the basic. You might want to add checks for things like nick changes (maybe tell them about grouping their nicks under one account for example), or rejoins (due to disconnects/netsplits) among other things. Also you may not want the bot to tell them that if they are already registered.

Jerry
  • 70,495
  • 13
  • 100
  • 144
  • Hi Jerry, that's exactly what i need! I just tested the script, but got no result and no error in Telnet session, I think something is missing, and I don't know what. Thank you so much for your time. – Fdcarvalho Mar 04 '20 at 10:04
  • @Fdcarvalho hmm try to put some prints in there, like a `putserv "NOTICE $nick :[array get joinedUsers]"` after the `set` in `pub:joinchan`, before and after the `if` of `pub:regchan` – Jerry Mar 04 '20 at 10:10
  • the `putserv notice` before the `if` of `pub:regchan` returns empty notice, the others `putserv notice` didn't give me nothing but `[10:28:03] Tcl error [pub:joinchan]: wrong # args: should be "pub:joinchan nick uhost handle chan"` or `putserv "NOTICE $nick :[array..."; should be "$putserv" or "{putserv}" or "putserv(...)" or ...` – Fdcarvalho Mar 04 '20 at 10:36
  • `*regist*canal*` is the text that users writes to receive the `Privmsg`, and is correct – Fdcarvalho Mar 04 '20 at 10:41
  • @Fdcarvalho Ok, looks I messed up. Try `pub join - "*!*@*" pub:joinchan` – Jerry Mar 04 '20 at 10:45