Skip to content

Commit

Permalink
Eventsub expierment
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaserlang committed Feb 29, 2024
1 parent fe79c31 commit 03c689e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions tbot/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def twitch_bot():
@cli.command()
def web():
set_logger('web.log')
from tbot.web.handlers.api.twitch.eventsubs.eventsub import task_check_channels
asyncio.run(task_check_channels())
import tbot.web.app
asyncio.run(tbot.web.app.main())

Expand Down
4 changes: 3 additions & 1 deletion tbot/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def App():
(r'/api/rtmp-auth', handlers.api.rtmp_auth.Handler),
(r'/api/srt-auth', handlers.api.srt_auth.Handler),

#(r'/api/twitch/webhooks/channel.subscribe', handlers.api.twitch.eventsubs.channel_subscribe.Handler),
(r'/api/twitch/webhooks/channel.subscribe', handlers.api.twitch.eventsubs.channel_subscribe.Handler),
(r'/api/twitch/webhooks/channel.subscribe.end', handlers.api.twitch.eventsubs.channel_subscribe_end.Handler),

(r"/api/twitch/widget-ws", handlers.api.twitch.widgets.widget_ws.Handler),

(r"/twitch/widgets/goal/([a-zA-Z0-9]+)", handlers.twitch.widgets.goal.Handler),
Expand Down
8 changes: 8 additions & 0 deletions tbot/web/handlers/api/twitch/eventsubs/channel_subscribe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from tbot import logger
from . import eventsub


class Handler(eventsub.Handler):

async def notification(self):
logger.info(self.request.body)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from tbot import logger
from . import eventsub


class Handler(eventsub.Handler):

async def notification(self):
logger.info(self.request.body)
12 changes: 8 additions & 4 deletions tbot/web/handlers/api/twitch/eventsubs/eventsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ class EventSubResponse(BaseModel, Generic[T]):

def channel_events(channel_id: str, scopes: list[str]):
events = [
#{
# 'type': 'channel.subscribe',
# 'scope': 'channel:read:subscriptions'
#}
{
'type': 'channel.subscribe',
'scope': 'channel:read:subscriptions'
},
{
'type': 'channel.subscription.end',
'scope': 'channel:read:subscriptions'
},
]
r = []
for e in events:
Expand Down

0 comments on commit 03c689e

Please sign in to comment.