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 

Channel message with variable number and frequency via query

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
needhelp2
Voice


Joined: 22 Sep 2011
Posts: 1

PostPosted: Sat Sep 24, 2011 8:13 pm    Post subject: Channel message with variable number and frequency via query Reply with quote

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
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Sat Oct 01, 2011 8:56 am    Post subject: Reply with quote

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

Code:

# 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
Back to top
View user's profile Send private message
annmary
Voice


Joined: 10 Dec 2011
Posts: 2

PostPosted: Sat Dec 10, 2011 8:43 am    Post subject: Reply with quote

hi, I have a question,
what is the meaning of this command
"
bind MSG m announce pAnnounceBind
"
cheers.
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sat Dec 10, 2011 10:47 am    Post subject: Reply with quote

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/1.6.20/tcl-commands.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/

Smile
Back to top
View user's profile Send private message
annmary
Voice


Joined: 10 Dec 2011
Posts: 2

PostPosted: Tue Dec 20, 2011 2:08 pm    Post subject: Reply with quote

thank you so much willyw
Wink
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
Page 1 of 1

 
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