forked from Wissididom/SafeGIF-Twitch-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (26 loc) · 1.46 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import webbrowser
from dotenv import load_dotenv
from bot import Bot
load_dotenv()
TWITCH_CLIENT_ID = os.getenv('TWITCH_CLIENT_ID', 'byvo5xr9mepepi9km69nfab44jbglk')
TWITCH_REDIRECT_URI = os.getenv('TWITCH_REDIRECT_URI', 'https://pasteme.local/')
INITIAL_CHANNELS = os.getenv('INITIAL_CHANNELS')
WHISPERS_ON_DELETION = True
WHISPER_TEXT = os.getenv('WHISPER_TEXT',
'Your message included an emote that could be triggering epilepsy so it was deleted')
SCOPES = 'chat%3Aread+chat%3Aedit+moderator%3Amanage%3Achat_messages+user%3Amanage%3Awhispers'
def main():
global TWITCH_CLIENT_ID, TWITCH_REDIRECT_URI, INITIAL_CHANNELS, SCOPES, WHISPERS_ON_DELETION, WHISPER_TEXT
if INITIAL_CHANNELS is None:
INITIAL_CHANNELS = input(
"Please enter the name of the channels you want the bot to monitor (separated by comma): ").strip()
webbrowser.open(
f"https://id.twitch.tv/oauth2/authorize?client_id={TWITCH_CLIENT_ID}&redirect_uri={TWITCH_REDIRECT_URI}&response_type=token&scope={SCOPES}&force_verify=true")
print("After you've authorized you get redirected to a non-existent page. Please copy+paste the url below!")
url = input('Paste the url twitch redirects you to here: ').strip()
access_token = url.split('#')[1].split('=')[1].split('&')[0]
bot = Bot(TWITCH_CLIENT_ID, access_token, INITIAL_CHANNELS.split(','), WHISPERS_ON_DELETION, WHISPER_TEXT)
bot.run()
if __name__ == '__main__':
main()