如何创建一个discord bot来发送有关流的通知? [英] How can I create a discord bot that will send out notifications about streams?

查看:81
本文介绍了如何创建一个discord bot来发送有关流的通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用PYTHON编写的discord机器人才能发送有关流开始的文本聊天通知.我尝试在IFTTT网站上使用webhooks来解决问题,但是这些警告会带来很大的延迟.有人可以抛弃一些用于通知流的代码吗?预先谢谢你

I need my discord bot written in PYTHON to be able to send a text chat notification about the start of the stream. I tried using webhooks in discord using the IFTTT site, but the alerts come with a huge delay. Can someone throw off some of the code for notification of streams? Thank you in advance

推荐答案

您可以使用Twitch的Eventsub在Stream上线时接收通知,然后修改有效负载以匹配Discord的Webhook格式并转发有效负载.实质上,这是IFTTT要做的.

You can use Twitch's Eventsub to recieve a notification when a Stream goes live then modify the payload to match Discord's Webhook format and forward the payload on. Which is essentially what IFTTT does anyway.

当前,EventSub仅提供Webhook传输.因此,您需要一个服务器"服务器.可以从Twitch接收HTTP帖子.

Currently EventSub only offers a Webhook Transport. So you need a "Server" that can recieve a HTTP Post from Twitch.

此处涵盖了Twitch EventSub https://dev.twitch.tv/docs/eventsub

Twitch EventSub is covered here https://dev.twitch.tv/docs/eventsub

此处包含Discord Webhooks https://discord.com/developers/docs/resources/webhook

Discord Webhooks is covered here https://discord.com/developers/docs/resources/webhook

如果您希望Discord Bot自己做,则通常不使用EventSub,因为您不希望Bot流程直接通过网络访问,因此您必须轮询Helix API的Streams端点定期测试流从脱机到联机的变化,并执行所需的任何操作.(或设置一个辅助过程来接收和内部中继数据)

If you want your Discord Bot to do it itself, then you generally would not use EventSub as you don't want your Bot process to be directly web accesable, so you'd have to poll the Streams Endpoint of the Helix API periodically and test for the Stream changing from offline to online and do whatever is needed. (Or setup a side process to recieve and internal relay the data)

您将使用Twitch应用程序访问/客户端凭据令牌,因为这是服务器到服务器的请求.

You would use a Twitch App Access/Client Credentials Token, since this is a server to server request.

这篇关于如何创建一个discord bot来发送有关流的通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆