• Home
  • Servers
  • Chat
  • Channels
  • Commands
  • Forum
  • FAQ
  • Software
  • Quotes
Topic Options
Rate This Topic
#1452 - 03/29/08 10:16 PM !time scripts
TuxedoJericho Offline
newbie

Registered: 12/24/07
Posts: 42
Loc: Whitesburg, TN
Hey guys, I wanted to share a really easy !time script for an mIRC bot. This is basically when the bot is just saying your time.

on 1:TEXT:!time:#channelname:/msg $chan $time

yeah, easy.

However, it if want to the bot to display the time for another user's chat, then here is a code that I found and edited to work. It is using #datalore and the timezone for Dublin

--------------------------

on 1:TEXT:!time*:#datalore:{
wtime dublin
}
alias wtime {
sockopen timed www.timeanddate.com 80
set %srch $1
}
on 1:SOCKOPEN:timed:{
sockwrite -n $sockname GET $+(/search/results.html?query=,%srch) HTTP/1.1
sockwrite -n $sockname Host: www.timeanddate.com
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname $crlf
}
on 1:SOCKREAD:timed:{
sockread %temp
if (<a href="/worldclock/city.html?n= isin %temp) { sockmark timed $remove($gettok(%temp,1,62),<a href=",") | wdtime }
if (<div class="minititle">No matches were found for*word</div> iswm %temp) { msg #testaway Sorry, No Match Found for $+(",,%srch,") | unset %srch }
}
alias wdtime {
sockopen wtimed www.timeanddate.com 80
}
on 1:sockopen:wtimed:{
sockwrite -n $sockname GET $+(/,$sock(timed).mark) HTTP/1.0
sockwrite -n $sockname Host: www.timeanddate.com
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname $crlf
}
on 1:sockread:wtimed:{
sockread %temp
if (<tr><th class="head" colspan="2"><span class="biggest">* iswm %temp) { /msg $chan ** $remove($gettok(%temp,4,62),</span) ** }
if (<tr class="d0"><th>Current time</th> isin %temp) { /msg #datalore Datalore's Current Time: $remove($gettok(%temp,5,60) $+(,$iif($remove($gettok(%temp,7,62),</a) == </td,,$remove($gettok(%temp,7,62),</a))) }
if (<tr><td>Standard time zone:</td> isin %temp) { /msg #datalore Datalore's current time: $remove($gettok(%temp,10,62), </td>) }
unset %srch
}

------------------------------

Now, I tried to get this to work for multiple channels, but it kept attempting to PM a user named CURRENT (who doesn't exist) instead of the channel name, so I had to set it to only trigger and reply in datalore's chat. Now, there is nothing against running separate versions of the script in the same bot for separate channels.

if you want to experiment with this and see if you can get it to work in multiple chats, then please have at it.

Edit: There seems to be a few weird gaps in the lower parts of the code when I preview. If there is, I apologize for that.
_________________________
I am Gary "TuxedoJericho" Greenlee, and I support this message.

Top
Sponsored Links
Sponsored Links
Member
*****

Registered: 27/08/04
Posts: 10136
Loc: Mountain View, CA
Top
#1454 - 03/29/08 10:31 PM Re: !time scripts [Re: TuxedoJericho]
Pctech37 Offline
newbie

Registered: 03/26/08
Posts: 35
Loc: Everett, WA
So weird i just almost posted that script! (dang)
_________________________
Hi. I am a forum signature virus. Paste me to your signature(s). *evil laugh*

Pctech37
G33k
Recognized WyldRyde Life Form
#Chris - VOP
#DavisCreation - SOP
#davisops - Founder
#gtaivchat - SOP
#Karol - HOP
#mancode - 5
#McInTEC - VOP
#pctech37 - Founder
#pctech37poker - Founder
#sports - Founder
#turtles - HOP

Top
#4479 - 03/10/09 01:11 AM Re: !time scripts [Re: Pctech37]
FordLawnmower Offline
Over 100 posts

Registered: 02/15/09
Posts: 111
Loc: Ohio
I made this one a long time ago but it still works fine.
Syntax is !time city state. It will also work with some countries
ie. !time paris france. It also does zip codes !time 45011 and airport codes !time cvg .
I'll post an update to this in a few days. I'm going over all my old scripts and fixing some old bugs smile
Code:
;***
;***
;Simple Time Script by Ford_Lawnmower
;This is a simple script that gets the time from a weather site of all places
;It could easily be edited to get the weather but there are many scripts for that ;/
;So I'll stick to the time
;It has a couple of bugs but it works most of the time ;/
;I think ;;||
;***
;***
alias time.timeout {
  if (%time.error.counter > 0) { .msg %time.chan 6Time not found. 7Suggestions:: %time.error.output | time.clear }
  else {
    .msg %time.chan No match was found for your search criteria %time.nick ... Please refine your search, be more specific or check your spelling... :(
    time.clear
  }
}
alias time.clear {
  unset %time*
  sockclose time
  .timer-time off
  halt
}
on *:TEXT:!time*:#: {
  if (%time.inuse == 1) { .notice $nick Sorry, But Somebody else is already looking up a their time. | time.clear }
  var %time.error.counter
  set %RAWtime.search $2-
  set %time.inuse 1
  set %time.nick $nick
  set %time.chan $chan
  sockclose time
  set %time.search $replacex($2-,$chr(32),+)
  set %timeurl /cgi-bin/findweather/getForecast?query= $+ %time.search
  set %timesite www.wunderground.com
  sockopen time %timesite 80
  .msg $chan 4 $chan 5Time Search... 7Searching for4 Your time 3Please Wait.....
  .timer-time 1 10 time.timeout
}
on *:sockopen:time: {
  sockwrite -n $sockname GET %timeurl HTTP/1.1
  sockwrite -n $sockname Host: %timesite $+ $CRLF $+ $CRLF
}
on *:sockread:time: {
  if ($sockerr > 0) { .msg %time.chan There has been an error... We could not retrive your Time. Sorry | time.clear }
  else {
    var %timevar |  sockread %timevar
    if (<td><a href="/global/ isin %timevar) || (<td><a href="/us/ isin %timevar) {
      set %time.error.output %time.error.output $+ 9<>6 $+ $httpstrip(%timevar)
      inc %time.error.counter
    }
    if (<span class="b"> isin %timevar) && ($upper(am) || $upper(pm) isin %timevar) {
      .msg %time.chan 4,1 The current time for %RAWtime.search is $httpstrip(%timevar)
      sockread %timevar
      time.clear
    }
  }
}
alias -l httpstrip {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}
_________________________
If you already know everything, You can never learn anything :P

Top
#4489 - 03/10/09 08:34 PM Re: !time scripts [Re: FordLawnmower]
FordLawnmower Offline
Over 100 posts

Registered: 02/15/09
Posts: 111
Loc: Ohio
Here it is. I re-parsed it and did some re-coding. It seems to work nice smile
Code:
;***
;***
;Simple Time Script by Ford_Lawnmower
;This is a simple script that gets the time from a weather site of all places
;It could easily be edited to get the weather but there are many scripts for that ;/
;So I'll stick to the time
;It has a couple of bugs but it works most of the time ;/
;I think ;;||
;***
;***
alias time.timeout {
  if (%time.chan == echo) { echo -a Connection was timed out... We could not find your time... :( }
  else { .msg %time.chan Connection was timed out...:( }
  time.clear
}
alias time.notfound {
  if (%time.chan == echo) { echo -a time not found. Try being more descriptive ie !time london england }
  else { .msg $chan Time not found. Try being more descriptive. ie !time london england }
  time.clear
}
alias time.clear {
  set %time.inuse 0
  unset %time*
  sockclose time
  .timer-time off
  halt
}
alias time {
  if (%time.inuse == 1) { echo -a time in use. To reset the script type /time.clear | return error1 | halt }
  set %time.inuse 1
  set %time.nick $me
  set %time.chan ECHO
  sockclose time
  set %timeurl /cgi-bin/findweather/getForecast?query= $+ $replace($1-,$chr(32),$chr(37) $+ 20) $+ &wuSelect=WEATHER&MR=1
  set %timesite www.wunderground.com
  ;echo -at opening http:// $+ %timesite $+ %timeurl
  sockopen time %timesite 80
  .timer-time 1 15 time.timeout
}
#WundergroundTime On
on *:TEXT:!time*:# {
  if (%time.inuse == 1) { .notice $nick Sorry, But Somebody else is already looking up a time. | halt }
  if (!$2) { .notice $nick Syntax !time city state/!time zipcode/!time airport code }
  set %time.inuse 1
  set %time.nick $nick
  set %time.chan $chan
  sockclose time
  set %timeurl /cgi-bin/findweather/getForecast?query= $+ $replace($2-,$chr(32),$chr(37) $+ 20) $+ &wuSelect=WEATHER&MR=1
  set %timesite www.wunderground.com
  sockopen time %timesite 80
  .msg $chan 4 $chan time finder... 7Searching for4 time 3Please Wait.....
  .timer-time 1 15 time.timeout
}
#WundergroundTime End
on *:sockopen:time: {
  sockwrite -n $sockname GET %timeurl HTTP/1.1
  sockwrite -n $sockname Host: %timesite $+ $CRLF $+ $CRLF
}
on *:sockread:time: {
  if ($sockerr > 0) { .msg %time.chan There has been an error... I could not retrive your Time Sorry |  time.clear }
  else {
    var %timevar |  sockread %timevar | set %time.line $calc(%time.line + 1)
    if (%time.line > 400) { time.notfound }
    if (There has been an error isin %timevar) { time.notfound }
    if (%time.place.found == on) { unset %time.place.found | set %time.place $httpstrip(%timevar) }
    if (<td class="nobr full"> isin %timevar) { set %time.place.found on }
    if (%time.time.found == on) {
      if (%time.chan == ECHO) {
        echo -a 07The current time for04 %time.place 06is09 $httpstrip(%timevar)
      }
      else {
        .msg %time.chan 07The current time for04 %time.place 06is09 $httpstrip(%timevar)
      }
      time.clear 
    }
    if (Local Time: isin %timevar) { set %time.time.found on }
  }
}
Menu Channel {
  .WundergroundTime
  ..Trigger On: .enable #WundergroundTime
  ..Trigger Off: .disable #WundergroundTime
}
alias -l httpstrip {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;,$chr(9))
  return %x
}
_________________________
If you already know everything, You can never learn anything :P

Top


Moderator:  Jeff, mandy, usrbingeek