You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before running the code below, there just a couple more steps we need to take.
30
33
31
34
#. Create a new Twitch account. This will be the dedicated bot account.
32
-
#. Enter your CLIENT_ID, CLIENT_SECRET, BOT_ID and OWNER_ID into the placeholders in the below example.
33
-
#. Comment out everything in ``setup_hook``.
34
-
#. Run the bot.
35
-
#. Open a new browser / incognito mode, log in as the bot account and visit http://localhost:4343/oauth?scopes=user:read:chat%20user:write:chat%20user:bot
36
-
#. In your main browser whilst logged in as your account, visit http://localhost:4343/oauth?scopes=channel:bot
37
-
#. Stop the bot and uncomment everything in ``setup_hook``.
38
-
#. Start the bot.
35
+
#. Enter your CLIENT_ID, CLIENT_SECRET, BOT_ID and OWNER_ID into the placeholders in the below example. See :ref:`faqs` on how to retrieve the ``BOT_ID`` and ``OWNER_ID``.
36
+
#. Run and start the bot from the code below.
37
+
#. Open a new browser / incognito mode, log in as the ``BOT ACCOUNT`` and visit http://localhost:4343/oauth?scopes=user:read:chat%20user:write:chat%20user:bot&force_verify=true
38
+
#. In your main browser whilst logged in as ``YOUR ACCOUNT``, visit http://localhost:4343/oauth?scopes=channel:bot&force_verify=true
39
+
#. You can now use chat commands in your channel!
39
40
40
41
.. note::
41
42
If you are unsure how to get the user IDs for BOT_ID and OWNER_ID, please check :ref:`bot-id-owner-id`
@@ -44,48 +45,75 @@ Before running the code below, there just a couple more steps we need to take.
44
45
45
46
.. code:: python3
46
47
48
+
"""An example of connecting to a conduit and subscribing to EventSub when a User Authorizes the application.
49
+
50
+
This bot can be restarted as many times without needing to subscribe or worry about tokens:
51
+
- Tokens are stored in '.tio.tokens.json' by default
52
+
- Subscriptions last 72 hours after the bot is disconnected and refresh when the bot starts.
53
+
54
+
Consider reading through the documentation for AutoBot for more in depth explanations.
55
+
"""
56
+
47
57
import asyncio
48
58
import logging
49
-
import sqlite3
59
+
import random
60
+
from typing import TYPE_CHECKING
50
61
51
62
import asqlite
63
+
52
64
import twitchio
53
-
from twitchio.ext import commands
54
65
from twitchio import eventsub
66
+
from twitchio.ext import commands
67
+
68
+
69
+
if TYPE_CHECKING:
70
+
import sqlite3
55
71
56
72
57
73
LOGGER: logging.Logger = logging.getLogger("Bot")
58
74
59
-
CLIENT_ID: str = "..." # The CLIENT ID from the Twitch Dev Console
60
-
CLIENT_SECRET: str = "..." # The CLIENT SECRET from the Twitch Dev Console
75
+
# Consider using a .env or another form of Configuration file!
76
+
CLIENT_ID: str = "..." # The CLIENT ID from the Twitch Dev Console
77
+
CLIENT_SECRET: str = "..." # The CLIENT SECRET from the Twitch Dev Console
61
78
BOT_ID = "..." # The Account ID of the bot user...
0 commit comments