Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
haugebot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dnns01
haugebot
Commits
64230d94
Commit
64230d94
authored
3 years ago
by
dnns01
Browse files
Options
Downloads
Patches
Plain Diff
Test for Eventsub
parent
e0b25637
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
haugebot_twitch/eventsub_cog.py
+36
-0
36 additions, 0 deletions
haugebot_twitch/eventsub_cog.py
haugebot_twitch/haugebot.py
+8
-0
8 additions, 0 deletions
haugebot_twitch/haugebot.py
with
44 additions
and
0 deletions
haugebot_twitch/eventsub_cog.py
0 → 100644
+
36
−
0
View file @
64230d94
import
os
from
functools
import
partial
from
twitchio.ext
import
eventsub
,
commands
from
dotenv
import
load_dotenv
load_dotenv
()
client_id
=
os
.
getenv
(
"
CLIENT_ID
"
)
client_secret
=
os
.
getenv
(
"
CLIENT_SECRET
"
)
client
=
commands
.
Bot
.
from_client_credentials
(
client_id
,
client_secret
)
class
EventSubCog
(
commands
.
Cog
):
def
__init__
(
self
,
bot
):
global
client
self
.
bot
=
bot
self
.
eventsub_client
=
eventsub
.
EventSubClient
(
client
,
"
trololololo
"
,
"
https://bottest.copycat-games.de/haugebot/callback
"
)
self
.
bot
.
loop
.
create_task
(
self
.
eventsub_client
.
listen
(
port
=
23456
))
async
def
subscribe
(
self
):
for
subscription
in
await
self
.
eventsub_client
.
get_subscriptions
():
await
self
.
eventsub_client
.
delete_subscription
(
subscription
.
id
)
await
self
.
eventsub_client
.
subscribe_channel_stream_start
(
87637599
)
await
self
.
eventsub_client
.
subscribe_channel_stream_end
(
87637599
)
lol
=
await
self
.
eventsub_client
.
get_subscriptions
()
print
(
lol
)
@client.event
()
async
def
event_eventsub_notification_stream_start
(
payload
:
eventsub
.
NotificationEvent
):
print
(
payload
)
@client.event
()
async
def
event_eventsub_notification_stream_end
(
payload
:
eventsub
.
NotificationEvent
):
print
(
payload
)
This diff is collapsed.
Click to expand it.
haugebot_twitch/haugebot.py
+
8
−
0
View file @
64230d94
import
os
from
abc
import
ABC
import
twitchio
from
dotenv
import
load_dotenv
from
twitchio
import
Channel
,
Message
from
twitchio.ext.commands
import
Context
,
Bot
...
...
@@ -8,6 +9,10 @@ from twitchio.ext.commands import Context, Bot
from
vote_cog
import
VoteCog
from
wusstest_du_schon
import
WusstestDuSchon
from
wordcloud
import
Wordcloud
from
eventsub_cog
import
EventSubCog
import
logging
logging
.
basicConfig
(
filename
=
"
haugebot.log
"
,
filemode
=
"
w
"
,
level
=
logging
.
DEBUG
,
)
class
HaugeBot
(
Bot
,
ABC
):
...
...
@@ -24,6 +29,7 @@ class HaugeBot(Bot, ABC):
self
.
add_cog
(
VoteCog
(
self
))
self
.
add_cog
(
WusstestDuSchon
(
self
))
self
.
add_cog
(
Wordcloud
(
self
))
self
.
add_cog
(
EventSubCog
(
self
))
@staticmethod
async
def
send_me
(
ctx
,
content
):
...
...
@@ -41,6 +47,8 @@ class HaugeBot(Bot, ABC):
wusstest_du_schon
.
loop
.
start
()
if
vote_cog
:
=
self
.
cogs
.
get
(
"
VoteCog
"
):
vote_cog
.
manage_vote
.
start
()
if
eventsub_cog
:
=
self
.
cogs
.
get
(
"
EventSubCog
"
):
await
eventsub_cog
.
subscribe
()
@staticmethod
def
get_percentage
(
part
,
total
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment