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 

Certain text message on certain timer

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


Joined: 14 Jun 2012
Posts: 2

PostPosted: Thu Jun 14, 2012 4:43 am    Post subject: Certain text message on certain timer Reply with quote

Hello,

I need an advertisment script that will let to add multiple text messages (supporting color codes/bold/underline) and set it to repeat each on certain timers (one message - 20 minutes, another - 40, for example). Would be good if they could be added via public commands. Searched public tcl archive for something like that - the only similar is http://forum.egghelp.org/viewtopic.php?t=18928

Something like mIRC /timer:

/timer 0 20 /msg #chan text
/timer 0 40 /msg #chan text2
...

Thanks in advance!

P.S. Can reward via Paypal Wink
Back to top
View user's profile Send private message
Fire-Fox
Master


Joined: 23 Sep 2006
Posts: 270
Location: /dev/null

PostPosted: Thu Jun 14, 2012 2:29 pm    Post subject: Reply with quote

Try this :

Should work:

Code:

proc putnoobuser { chan nick } {
   putserv "NOTICE $nick : $nick You dont have the needed access!"
}

bind pub -|- !addnews pub_doadvertisment
bind pub -|- !deletenews pub_killadvertisment

#######################
## Make Advertisment ##
#######################
proc pub_doadvertisment {nick uhost hand chan arg} {
global advertismentid advertismenttime
   
if {![isop $nick $chan]} {putnoobuser $chan $nick ; return 0}
set advertisment [join [lrange [split $arg] 1 end]]
set advertismenttime [lindex [split $arg] 0]   
set advertismentid($advertisment) [timer $advertismenttime [list showadvertisment $chan $advertisment $advertisment]]
putserv "NOTICE $nick :Advertisment \"$advertisment\" is now createt with interval $advertismenttime min(s)"
}
#################
##     End     ##
#################

#######################
## Show Advertisment ##
#######################
proc showadvertisment {chan id advertisment} {
global advertismentid advertismenttime
set advertisment [join [lrange [split $advertisment] 0 end]]   
putserv "PRIVMSG $chan :Advertisment: $advertisment"
set advertismentid($advertisment) [timer $advertismenttime [list showadvertisment $chan $advertisment $advertisment]]
}
#################
##     End     ##
#################

#######################
## Kill Advertisment ##
#######################
proc pub_killadvertisment {nick uhost hand chan arg} {
global advertismentid advertismenttime

if {![isop $nick $chan]} {putnoobuser $chan $nick ; return 0}
set arg [join [lrange [split $arg] 0 end]]
killtimer $advertismentid($arg)
putserv "NOTICE $nick :Advertisment \"$arg\" is now deletet"
}
#################
##     End     ##
#################

putlog "Advertisment Loaded"

_________________
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze


Last edited by Fire-Fox on Thu Jun 14, 2012 4:49 pm; edited 3 times in total
Back to top
View user's profile Send private message MSN Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Jun 14, 2012 2:41 pm    Post subject: Reply with quote

A few remarks...
Code:
set advertismentid($advertisment) [timer $advertismenttime "showadvertisment $chan \"$advertisment\" \"$advertisment\""]

This is a very bad way of starting timers.. Since the contents of advertisment originates from a possibly untrusted user, it could contain malicious things such as [adduser badboy *!*@*] and [chattr badboy +n].
As the timer expires, that would be executed, adding a new user to the bot with owner privileges...

The proper way is to use list
Code:
set advertismentid($advertisment) [timer $advertismenttime [list showadvertisment $chan $advertisment $advertisment]]


Code:
set advertismenttime [join [lrange [split $arg] 0 0]]

This could be simplified:
Code:
set advertismenttime [lindex [split $arg] 0]


Code:
set arg [join [lrange [split $arg] 0 end]]

This is pretty much a no-op... you split the string to a list, select a subset from the first to the last element (inclusive, being the whole list), and then convert it back into a string (should be the very same string you started with).
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
alxd
Voice


Joined: 14 Jun 2012
Posts: 2

PostPosted: Thu Jun 14, 2012 2:44 pm    Post subject: Reply with quote

Fire-Fox wrote:
Try this :

Should work:

Code:

proc putnoobuser { chan nick } {
   putserv "NOTICE $nick : $nick You dont have the needed access!"
}

bind pub -|- !addnews pub_doadvertisment
bind pub -|- !deletenews pub_killadvertisment

#######################
## Make Advertisment ##
#######################
proc pub_doadvertisment {nick uhost hand chan arg} {
global advertismentid advertismenttime
   
if {![isop $nick $chan]} {putnoobuser $chan $nick ; return 0}
set advertisment [join [lrange [split $arg] 1 end]]
set advertismenttime [join [lrange [split $arg] 0 0]]   
set advertismentid($advertisment) [timer $advertismenttime "showadvertisment $chan \"$advertisment\" \"$advertisment\""]
putserv "NOTICE $nick :Advertisment \"$advertisment\" is now createt with interval $advertismenttime min(s)"
}
#################
##     End     ##
#################

#######################
## Show Advertisment ##
#######################
proc showadvertisment {chan id advertisment} {
global advertismentid advertismenttime
set advertisment [join [lrange [split $advertisment] 0 end]]   
putserv "PRIVMSG $chan :Advertisment: $advertisment"
set advertismentid($advertisment) [timer $advertismenttime "showadvertisment $chan \"$advertisment\" \"$advertisment\""]
}
#################
##     End     ##
#################

#######################
## Kill Advertisment ##
#######################
proc pub_killadvertisment {nick uhost hand chan arg} {
global advertismentid advertismenttime

if {![isop $nick $chan]} {putnoobuser $chan $nick ; return 0}
set arg [join [lrange [split $arg] 0 end]]
killtimer $advertismentid($arg)
putserv "NOTICE $nick :Advertisment \"$arg\" is now deletet"
}
#################
##     End     ##
#################

putlog "Advertisment Loaded"


22:36:46 me: advadd 1 test001
22:36:54 bot: Advertisment "test001" activated with interval 1 min(s)
22:37:01 bot: test001

I added 1 minute, but it works much earlier.. + if I add second advertisment, it performs with more delay but only one time

Also, there's lack of advertisments list command and there can be added empty message to timer.

bot: Advertisment "" activated with interval test min(s)

Thanks in advance!
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