| View previous topic :: View next topic |
| Author |
Message |
alxd Voice
Joined: 14 Jun 2012 Posts: 2
|
Posted: Thu Jun 14, 2012 4:43 am Post subject: Certain text message on certain timer |
|
|
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  |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Thu Jun 14, 2012 2:29 pm Post subject: |
|
|
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Jun 14, 2012 2:41 pm Post subject: |
|
|
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 |
|
 |
alxd Voice
Joined: 14 Jun 2012 Posts: 2
|
Posted: Thu Jun 14, 2012 2:44 pm Post subject: |
|
|
| 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 |
|
 |
|