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.

Channel message with variable number and frequency via query

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
n
needhelp2
Voice
Posts: 1
Joined: Thu Sep 22, 2011 11:38 pm

Channel message with variable number and frequency via query

Post by needhelp2 »

Hello, I have searched quite extensively for a script, that will send a message to a channel, variable number of times. The closest I have found, is darkbot's repeat command, but that is not an eggdrop.

I would be thankful, if someone were to replicate the feature in eggdrop form, for me.The default being, that it would start as soon as you give the message/announcement, every hour, for a day. So, an example of the default behavior would be "/msg bot message", where the message/announcement would repeat, as soon as it was sent, every hour, for a day. If the command was issued at 11:23 AM 09/26/2011, the final annoucement would be at 10:23 AM 09/27/2011. Also, another example would be, "/msg bot 15 8 message" - it would send the message/announcement every 15 minutes, eight times and then stop.

I do appreciate your help on the matter, greatly.

Thank you.

Cheers,

needhelp
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Give this a try. I've done some minimal testing

Code: Select all

# announce.tcl

# /msg <botnick> announce ?#channelname? ?frequency? ?number? <message>
# first announcement will be after 1 minute, thereafter at the frequency specified

### ----------------------------------------------------------------------- ###
### ---------- Configuration (edit as required) --------------------------- ###

# set here the default bot channel for announcements
set vAnnounceDefaultChannel "#eggtcl"

# set here the default frequency in minutes that the announcement is made
set vAnnounceDefaultFrequency 2

# set here the default number of times the announcement is made
set vAnnounceDefaultNumber 10

### ----------------------------------------------------------------------- ###
### ---------- Code (do not edit) ----------------------------------------- ###

bind MSG m announce pAnnounceBind

proc pAnnounceBind {nick uhost hand text} {
    global vAnnounceDefaultChannel vAnnounceDefaultFrequency vAnnounceDefaultNumber
    regexp -- {^(#[^\s]+\s)?([1-9][0-9]*\s)?([1-9][0-9]*\s)?(.+)?} [regsub -all -- {\s{2,}} [string trim $text] { }] -> channel frequency number message
    if {[string length $channel] == 0} {set channel $vAnnounceDefaultChannel} else {set channel [string trimright $channel]}
    if {[string length $frequency] == 0} {set frequency $vAnnounceDefaultFrequency} else {set frequency [string trimright $frequency]}
    if {[string length $number] == 0} {set number $vAnnounceDefaultNumber} else {set number [string trimright $number]}
    if {[string length $message] != 0} {
        if {[validchan $channel]} {
            putserv "NOTICE $nick :announcing message at $frequency minute intervals $number time(s) in $channel"
            for {set loop 0} {$loop < $number} {incr loop} {
                timer [expr {($loop * $frequency) + 1}] [list pAnnounceMessage $channel $message]
            }
        } else {putserv "NOTICE $nick :bot does not have a channel record for $channel"}
    } else {putserv "NOTICE $nick :usage /msg <botnick> announce ?#channelname? ?frequency? ?number? <message>"}
    return 0
}

proc pAnnounceMessage {channel message} {
    if {[botonchan $channel]} {
        putserv "PRIVMSG $channel :$message"
    }
    return 0
}

# eof
*** edited, adding ^ to beginning of regexp pattern to ensure arguments are only matched from the start of the text
*** also added m flag to bind, to ensure only global master or above can use it
I must have had nothing to do
a
annmary
Voice
Posts: 2
Joined: Sat Dec 10, 2011 8:41 am

Post by annmary »

hi, I have a question,
what is the meaning of this command
"
bind MSG m announce pAnnounceBind
"
cheers.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Makes bot react to a specific /msg. In this case, "announce".
The single letter - m - is a limiting flag... in your example, the user send the /msg must have a user record in the bot, and have the m flag. If not, the /msg is ignored.
If a user does have the m flag, and sends /msg announce to the bot, bot will react by running procedure named pAnnounceBind.

This is an excellent reference for all the binds (and other TCL Eggdrop commands):
http://www.eggheads.org/support/egghtml ... html#binda

I think this is a very good site for beginning with TCL for Eggdrop:
http://suninet.the-demon.de/
Even though it is old, it gets you started. It is easy to read, and easy to understand.

For your specific question, here is the link:
http://suninet.the-demon.de/04.htm


p.s.
I see this is your first post here. Welcome!
Tip: If you have more questions about this, it would be better if you start your own thread. Probably in the Scripting Help section.
http://forum.egghelp.org/

:)
a
annmary
Voice
Posts: 2
Joined: Sat Dec 10, 2011 8:41 am

Post by annmary »

thank you so much willyw
:wink:
Post Reply