mirror of
https://github.com/kurbezz/discord-bot.git
synced 2025-12-06 07:05:36 +01:00
Add chatbot_in_chats
This commit is contained in:
@@ -30,3 +30,5 @@ class StreamerConfig(BaseModel):
|
|||||||
twitch: TwitchConfig
|
twitch: TwitchConfig
|
||||||
notifications: NotificationsConfig
|
notifications: NotificationsConfig
|
||||||
integrations: IntegrationsConfig
|
integrations: IntegrationsConfig
|
||||||
|
|
||||||
|
chatbot_in_chats: list[int] | None = None
|
||||||
|
|||||||
@@ -100,17 +100,20 @@ class TwitchService:
|
|||||||
await eventsub.listen_channel_update_v2(str(streamer.twitch.id), self.on_channel_update)
|
await eventsub.listen_channel_update_v2(str(streamer.twitch.id), self.on_channel_update)
|
||||||
case "listen_stream_online":
|
case "listen_stream_online":
|
||||||
await eventsub.listen_stream_online(str(streamer.twitch.id), self.on_stream_online)
|
await eventsub.listen_stream_online(str(streamer.twitch.id), self.on_stream_online)
|
||||||
case "listen_channel_chat_message":
|
|
||||||
await eventsub.listen_channel_chat_message(
|
|
||||||
str(streamer.twitch.id),
|
|
||||||
str(config.TWITCH_ADMIN_USER_ID),
|
|
||||||
self.on_message
|
|
||||||
)
|
|
||||||
case "listen_channel_points_custom_reward_redemption_add":
|
case "listen_channel_points_custom_reward_redemption_add":
|
||||||
await eventsub.listen_channel_points_custom_reward_redemption_add(
|
await eventsub.listen_channel_points_custom_reward_redemption_add(
|
||||||
str(streamer.twitch.id),
|
str(streamer.twitch.id),
|
||||||
self.on_channel_points_custom_reward_redemption_add
|
self.on_channel_points_custom_reward_redemption_add
|
||||||
)
|
)
|
||||||
|
case "listen_channel_chat_message":
|
||||||
|
chatbot_in_chats = streamer.chatbot_in_chats or []
|
||||||
|
|
||||||
|
for chat_id in chatbot_in_chats:
|
||||||
|
await eventsub.listen_channel_chat_message(
|
||||||
|
str(chat_id),
|
||||||
|
str(streamer.twitch.id),
|
||||||
|
self.on_message
|
||||||
|
)
|
||||||
case _:
|
case _:
|
||||||
raise ValueError("Unknown method")
|
raise ValueError("Unknown method")
|
||||||
|
|
||||||
@@ -127,8 +130,8 @@ class TwitchService:
|
|||||||
await gather(
|
await gather(
|
||||||
self.subscribe_with_retry("listen_channel_update_v2", eventsub, streamer),
|
self.subscribe_with_retry("listen_channel_update_v2", eventsub, streamer),
|
||||||
self.subscribe_with_retry("listen_stream_online", eventsub, streamer),
|
self.subscribe_with_retry("listen_stream_online", eventsub, streamer),
|
||||||
# self.subscribe_with_retry("listen_channel_chat_message", eventsub, streamer),
|
self.subscribe_with_retry("listen_channel_points_custom_reward_redemption_add", eventsub, streamer),
|
||||||
self.subscribe_with_retry("listen_channel_points_custom_reward_redemption_add", eventsub, streamer)
|
self.subscribe_with_retry("listen_channel_chat_message", eventsub, streamer),
|
||||||
)
|
)
|
||||||
logger.info(f"Subscribe to events for {streamer.twitch.name} done")
|
logger.info(f"Subscribe to events for {streamer.twitch.name} done")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user