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.

Timed Message

Old posts that have not been replied to for several years.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

set msges {
"My random msg no 1"
"My random msg no 2"
"My random msg no 3"
"My random msg no 4"
"My random msg no 5"
}

bind pub n !random random:pub

proc random:pub {nick host hand chan arg} {
global msges
putserv "PRIVMSG $chan :[lindex $msges [rand [llength $msges]]]"
}

This will say an random line from the 'msges' list. Use it as an example.
Once the game is over, the king and the pawn go back in the same box.
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

ok - will try to figure out how that relates to the script above lol
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

# Set this in the format "MIN:HOUR:DAY:MONTH:YEAR"
# Not all fields are needed. THe more included, the more precices the timer
# Feilds can be omited, by leaving them blank. All feilds are 2 digits (though year may be 4)
# EG
# Miday = 00:12
# Every hour = 00
# Every hour, only on the 2nd of the month = 00::02
set timed(mask) "00:12"

# Set the channel the msg'es will be sent
set timed(channel) "#channel"

# What msg'es to send
set timed(msges) {
"Our message goes here, in IRCD command format"
"Another msg goes here"
"Here another"
}

bind time - "*" message:timed
proc message:timed {args} {
global timed
set idx 0
set temp [split $timed(mask) :]
foreach a $args {
if {([lindex $temp $idx] == [lindex $args $idx]) || ([lindex $temp $idx] == "")} {
incr idx
continue
} else {
return
}
}
puthelp "PRIVMSG $timed(channel) :[lindex $timed(msges) [rand [llength $timed(msges)]]]"
}

Guess who is borring round here.. :]
Once the game is over, the king and the pawn go back in the same box.
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

thanks - thing is tho, I want one specific msg to go at 00:12, another at 00:13, and so on for 24 msgs (one for every hour) not just random msgs going at the time - so wont I need to state somewhere all the different times for the various mesages? (im using it like a clock that will announce the time of day to the channel and a message after it)

like this which I currently do on a mIRC bot:

[09:00:00] <News24> 09:00 New York - 08:00 Chicago - 30 mins to U.S. Opening Bell (Mon-Fri)

sorry for the trouble - thanks for the help =)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

So, basicaly you want 12 different msg to be said in channel at 00:12.. 00:13.. 00:24, right?

Oh, and next time please be more specific on the things you ask.
Once the game is over, the king and the pawn go back in the same box.
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

24 msgs - one for each hour - 00:00 thru 00:23 - all saying something different...
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

more specific? I have been if you read above!
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

anyone able to help me finish solving this one...?

:(
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Aww, you should have tried it yourself first. In the long run it pays to find things out. Ppslim already gave you 99% of the code!

Code: Select all

set timemsg(01) "some message for 1am"
set timemsg(03) "some message for 3am"
set timemsg(15) "some message for 3pm... etc..."

bind time - "00 * * * *" hourly_message
proc hourly_message {min hour day month year} {
  global timemsg
  if {[info exists timemsg($hour)]} {
    putserv "privmsg #sheep :$timemsg($hour)"
  }
  return 0
}
No guarantees that it works, I don't have time to test. But it probably will. I'm good like that.
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

hehe thanks st - yeah I did try a few things - looks like I was sort of on the right track - just didn't use the brackets...

thanks again! will give this a shot now =)
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

hi again - it's working - if I also have a msg for a some times at the half-hour, would this be right...?


set timemsg(30:15) "some message for 3.30pm... etc..."

bind time - "* * * * *" hourly_message
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

sorry, actually that piece of script above dosn't work correctly - it seems to post the msg to the channel once a minute every minute...

I had to kill the bot to get it to stop...

this is turning out to be very tricky indeed!

:-? :-?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You did say "24 msgs - one for each hour - 00:00 thru 00:23 - all saying something different..." and didn't mention half-hours or anything. This is only turning out to be tricky because you are being rather unclear! So are you saying you want this to work for *any* time?
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

yes...sorry - I have a few other timers for other various times - not only on-the-hour

sorry again...
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You almost had it! You changed the right parts, the only other thing you had to do was change timemsg($hour) to timemsg($hour:$min). (I also changed the name of the proc because hourly_message doesn't make sense anymore.)

Code: Select all

set timemsg(01:00) "some message for 1am"
set timemsg(03:15) "some message for 3:15am"
set timemsg(15:00) "some message for 3pm... etc..."

bind time - "* * * * *" timed_message
proc timed_message {min hour day month year} {
  global timemsg
  if {[info exists timemsg($hour:$min)]} {
    putserv "privmsg #sheep :$timemsg($hour:$min)"
  }
  return 0
}
Locked