swaping methods to another file
This commit is contained in:
parent
10eab70e22
commit
d9ae68b21b
2 changed files with 19 additions and 19 deletions
22
src/main.py
22
src/main.py
|
@ -1,22 +1,6 @@
|
||||||
from twitchio.ext import commands
|
from twitchio.ext import commands
|
||||||
from os import environ, listdir
|
from os import listdir
|
||||||
from dotenv import load_dotenv
|
from utils.utils import load
|
||||||
from sys import exit
|
|
||||||
|
|
||||||
path = 'todo.txt'
|
|
||||||
|
|
||||||
def load(variables):
|
|
||||||
"""Load env variables"""
|
|
||||||
keys = {}
|
|
||||||
load_dotenv()
|
|
||||||
for var in variables:
|
|
||||||
try:
|
|
||||||
keys[var] = environ[var]
|
|
||||||
except KeyError:
|
|
||||||
print(f"Please set the environment variable {var} (.env file supported)")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
return keys
|
|
||||||
|
|
||||||
class Bot(commands.Bot):
|
class Bot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -24,7 +8,7 @@ class Bot(commands.Bot):
|
||||||
super().__init__(token=self.keys["ACCESS_TOKEN"], prefix=self.keys["PREFIX"], initial_channels=['mylloon'])
|
super().__init__(token=self.keys["ACCESS_TOKEN"], prefix=self.keys["PREFIX"], initial_channels=['mylloon'])
|
||||||
|
|
||||||
async def event_ready(self):
|
async def event_ready(self):
|
||||||
print(f'Logged in on {self.nick}')
|
print(f"Logged in as {self.nick}")
|
||||||
|
|
||||||
async def event_message(self, message):
|
async def event_message(self, message):
|
||||||
if message.echo: # Messages with echo set to True are messages sent by the bot
|
if message.echo: # Messages with echo set to True are messages sent by the bot
|
||||||
|
|
16
src/utils/utils.py
Normal file
16
src/utils/utils.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from os import environ
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from sys import exit
|
||||||
|
|
||||||
|
def load(variables):
|
||||||
|
"""Load env variables"""
|
||||||
|
keys = {}
|
||||||
|
load_dotenv()
|
||||||
|
for var in variables:
|
||||||
|
try:
|
||||||
|
keys[var] = environ[var]
|
||||||
|
except KeyError:
|
||||||
|
print(f"Please set the environment variable {var} (.env file supported)")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
return keys
|
Loading…
Reference in a new issue