IRC bot help - uptime

Helping a friend with a custom bot and we can’t find a way to code uptime into the customer bot outside a timer and we rather not use timer commands because someone has to start it. Looking for maybe like what nightbot and other bots have for coding to show the uptime :)!

Thanks for help in advance ! Stay awesome!

This is the way I get the uptime of a stream: or

Search for up_time. You will get the date and time when the stream started.



If you’re looking for a mIRC bot based here it is:

on *:text:!uptime:#channel_here:{

alias uptime {
  sockopen tuptime 80

on *:sockopen:tuptime:{
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /api/stream/list.xml?channel=channel_name HTTP/1.1
  sockwrite -n $sockname Host: $crlf $+ $crlf

on *:sockread:tuptime:{
  if ($sockerr) { sockclose $sockname }
  var %streamodata
  sockread %streamodata

  if ($regex(%streamodata,/<up_time>(.*)</up_time>/)) {
    msg #channel_here [Uptime] Streamname_here is online for $duration($calc($ctime - $ctime($regml(1)))) $+ .

Does anyone have an updated version that works now that doesn’t exist anymore? I tried to use Though I was not able to get it to work. Would greatly appreciate this.

Which programming language are you writing the bot in?
No one can help before they know that since there are so many to choose from.

The API URL has been updated.
Here you can find all you need to know about the API

I am trying to get uptime to work in C#, but whenever I substract created_at from DateTime.Now the uptime is off by a few hours.
Probably due to the timezone difference between created_at and the server.

How can I get around this?

string created_at = (string)((JObject)value)["created_at"];
return DateTime.Now - DateTime.Parse(created_at);

created_at is UTC, so ensure it is parsed as UTC and your DateTime.Now is in UTC.

1 Like

Sorry about the delay. I am scripting with IRC right now. Trying to impliment uptime so that I can use it to use the time to create a highlight time stamp/marker.