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.

Certain text message on certain timer

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
a
alxd
Voice
Posts: 2
Joined: Thu Jun 14, 2012 4:39 am

Certain text message on certain timer

Post by alxd »

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 ;)
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

Post by Fire-Fox »

Try this :

Should work:

Code: Select all

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"
Last edited by Fire-Fox on Thu Jun 14, 2012 4:49 pm, edited 3 times in total.
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

A few remarks...

Code: Select all

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: Select all

set advertismentid($advertisment) [timer $advertismenttime [list showadvertisment $chan $advertisment $advertisment]]

Code: Select all

set advertismenttime [join [lrange [split $arg] 0 0]]
This could be simplified:

Code: Select all

set advertismenttime [lindex [split $arg] 0]

Code: Select all

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
a
alxd
Voice
Posts: 2
Joined: Thu Jun 14, 2012 4:39 am

Post by alxd »

Fire-Fox wrote:Try this :

Should work:

Code: Select all

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!
Post Reply