swaping methods to another file

This commit is contained in:
Mylloon 2021-07-27 03:02:51 +02:00
parent 10eab70e22
commit d9ae68b21b
2 changed files with 19 additions and 19 deletions

View file

@ -1,22 +1,6 @@
from twitchio.ext import commands
from os import environ, listdir
from dotenv import load_dotenv
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
from os import listdir
from utils.utils import load
class Bot(commands.Bot):
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'])
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):
if message.echo: # Messages with echo set to True are messages sent by the bot

16
src/utils/utils.py Normal file
View 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