!UpTime Twitch command (TwitchBot C#)

六眼飞鱼酱① 提交于 2019-12-25 09:25:58

问题


I was wondering how I would add a command for 'UpTime' in my commands that will show how long the twitch channel has been live for.

This is my whole code: https://pastebin.com/ty8J3vYS

Im not sure if i add it into my commands with things added to it with another case such as

                case "uptime":
                    irc.sendChatMessage("");
                break;

Any help/guidance would be great.

Thanks in advanced.


回答1:


You can use Twitch's own API for this. Using this URL:

https://api.twitch.tv/kraken/streams/CHANNEL_ID

CHANNEL_ID is numeric, so you'll have to find out what yours is.

Will return json, and within it contains the key created_at, which tells you when a stream went live, and from there you can calculate how long the stream has been live for. (curr_date - created_at)

Although, you will need a Client-ID when sending the API request. You can read more about that here:

https://blog.twitch.tv/client-id-required-for-kraken-api-calls-afbb8e95f843

Here is the documentation on Twitch's API: https://dev.twitch.tv/docs/



来源:https://stackoverflow.com/questions/44134600/uptime-twitch-command-twitchbot-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!