mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
Hello, I was wondering if someone could write a hello script that would get the time from the person who joined, then pull a random message from a txt file according to the time? Have it so that there is four time fields: Morning (5am-11am), Afternoon (12pm-5pm), Night (6pm - 12am) and Midnight (1am-4am).

Would this be possible or is it too complex for mIRC?

Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Yes this is possible.

Here is a script, that should do what you want:

Code:
on *:JOIN:[color:blue]#channelname[/color]:{
  ctcp $nick Time
}

on *:CTCPREPLY:TIME*:{
  var %timereply = $2-
  if (($5 >= 05:00:00) && ($5 <= 11:59:59)) { msg [color:blue]#channelname[/color] Good morning $nick $+ . }
  elseif (($5 >= 12:00:00) && ($5 <= 17:59:59)) { msg [color:blue]#channelname[/color] Good afternoon $nick $+ . }
  elseif (($5 >= 18:00:00) && ($5 <= 23:59:59)) { msg [color:blue]#channelname[/color] Good evening $nick $+ . }
  elseif (($5 >= 00:00:00) && ($5 <= 04:59:59)) { msg [color:blue]#channelname[/color] Good night $nick $+ . }
  else { msg [color:blue]#channelname[/color] Hi $nick $+ . }
}


Obviously, change #channelname, to the name of the channel you want it to work in.

Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
Thanks. I should be able to change the msg thing so it reads a random line form a txt file myself. Thanks.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You could change that last elseif to just else and remove the else at the end of the code, as the if/elseif statements, in that order, cover all 24 hours of the day.

Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
One question, is there a way of making this script not activate if a nick has rejoined the channel within 5 minutes of pinging out or if there is currently a nick within the channel that is similiar, comparing the first 3 characters of the nick?

ie) If Kareesh is within the channel currently and then joins as Kar_Bed. The script would not welcome Kar_Bed as this is abviously a ping re-join.

or

Kareesh ping out and 4 minutes later, joins again as Kareesh again. The script would not activate.


Could these two thing be worked into the above script, or would this be impossible?

Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Hmmm, that I wouldn't know.
I think it is possible with hash-tables, but then someone else will need to reply. I wouldn't know how to do it.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
It can be done, however, I can't work on it at the moment as I'm expecting company any time now. Also, for your random messages, since you want them based upon the time, I would suggest organizing them in the text file under topic headings.
Eg: [Morning]
Good Morning $nick $+ . Did you sleep well?
Hi $nick ... Uh-oh looks like someone could use some more shut eye
[Afternoon]
Did you remember to have some lunch?


I'm sure you get the idea and can expand on the specifics yourself.

Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
I get the pattern, though I have never used Headings in a text file, so wouldn't know how to work with them.

And thanks for your time guys and efforts.

Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Quote:
You could change that last elseif to just else and remove the else at the end of the code, as the if/elseif statements, in that order, cover all 24 hours of the day.


Well, I put that extra else statement, for in case people altered their default ctcp time reply. In that case $5 could be anything.

The var %timereply can be removed though, I only used it for testing the reply and forgot to remove it.

Joined: Jul 2006
Posts: 10
O
Pikka bird
Offline
Pikka bird
O
Joined: Jul 2006
Posts: 10
Quote:
One question, is there a way of making this script not activate if a nick has rejoined the channel within 5 minutes of pinging out or if there is currently a nick within the channel that is similiar, comparing the first 3 characters of the nick?

ie) If Kareesh is within the channel currently and then joins as Kar_Bed. The script would not welcome Kar_Bed as this is abviously a ping re-join.

or

Kareesh ping out and 4 minutes later, joins again as Kareesh again. The script would not activate.


Could these two thing be worked into the above script, or would this be impossible?


yes this is possible....

Code:
 
on *:JOIN:[color:blue]#channelname[/color]: {
  ;Checking to see if the person is already been checked within the last 300 seconds
  if (% [ $+ [ $chan ] ] [ $+ [ $chr(46) ] ] [ $+ [ $gettok($gettok($address($nick,2),1,46),2,64) $+ . ] ] [ $+ [ $gettok($address($nick,2),2,46) ] ] != 1) { 
    ;Setting the $nick to ignore list (for this script only)
    set % [ $+ [ $chan ] ] [ $+ [ $chr(46) ] ] [ $+ [ $gettok($gettok($address($nick,2),1,46),2,64) $+ . ] ] [ $+ [ $gettok($address($nick,2),2,46) ] ] 1
    ;Check the time of the $nick
    ctcp $nick Time
    ;Set this timer to message the $nick again ( you can change the timer to anything if u wish, i tested with 300 seconds and it worked  :) )
    timer 1 300 unset % [ $+ [ $chan ] ] [ $+ [ $chr(46) ] ] [ $+ [ $gettok($gettok($address($nick,2),1,46),2,64) $+ . ] ] [ $+ [ $gettok($address($nick,2),2,46) ] ] 
  }
}

on *:CTCPREPLY:TIME*: {
  if (($5 >= 05:00:00) && ($5 <= 11:59:59)) { 
    msg [color:blue]#channelname[/color] Good morning $nick $+ . 
  }  
  elseif (($5 >= 12:00:00) && ($5 <= 17:59:59)) { 
    msg [color:blue]#channelname[/color] Good afternoon $nick $+ . 
  }  
  elseif (($5 >= 18:00:00) && ($5 <= 23:59:59)) {
    msg [color:blue]#channelname[/color] Good evening $nick $+ . 
  }
  elseif (($5 >= 00:00:00) && ($5 <= 04:59:59)) {
    msg [color:blue]#channelname[/color] Good night $nick $+ .
  }
  else { 
    msg [color:blue]#channelname[/color] Hi $nick $+ . 
  }
}


Change #channelname to your channel...

i know the script may seem messy smile but it actually works smile

-- If u have any problems with the script, u can contact me on irc.GameSurge.Net in #mirc (i use the nicks Axl, Axel or omgwtfbbqhax)


Link Copied to Clipboard