Browse Source

Install as Python package

news
Martin Mareš 2 years ago
parent
commit
df44328c35
  1. 12
      bin/hrochobot
  2. 0
      hrochobot/cogs/basic.py
  3. 2
      hrochobot/cogs/ksp.py
  4. 2
      hrochobot/cogs/roles.py
  5. 2
      hrochobot/utils/data.py
  6. 0
      hrochobot/utils/ksp_utils.py
  7. 19
      setup.py

12
main.py → bin/hrochobot

@ -1,11 +1,15 @@
#!/usr/bin/env python3
from discord.ext import commands
import utils.data as data
import hrochobot.utils.data as data
import logging
import os
logger = logging.getLogger('discord')
data.DATA_FOLDER = os.environ.get("HROCHOBOT_DATA", 'data')
LOG_FOLDER = os.environ.get("HROCHOBOT_LOG", '.')
logger = logging.getLogger('hrochobot')
logger.setLevel(logging.INFO)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler = logging.FileHandler(filename=f'{LOG_FOLDER}/hrochobot.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
@ -20,7 +24,7 @@ cogs_list = [
]
for cog in cogs_list:
bot.load_extension(f'cogs.{cog}')
bot.load_extension(f'hrochobot.cogs.{cog}')
@bot.listen('on_interaction')
async def statistics(interaction):

0
cogs/basic.py → hrochobot/cogs/basic.py

2
cogs/ksp.py → hrochobot/cogs/ksp.py

@ -1,6 +1,6 @@
import discord
from discord.ext import commands
from utils.ksp_utils import *
from hrochobot.utils.ksp_utils import *
class Ksp(commands.Cog):
def __init__(self, bot):

2
cogs/roles.py → hrochobot/cogs/roles.py

@ -1,5 +1,5 @@
import discord
import utils.data as data
import hrochobot.utils.data as data
from discord.ext import commands
from discord.utils import get

2
utils/data.py → hrochobot/utils/data.py

@ -2,7 +2,7 @@ from typing import Any
import json
import os.path
DATA_FOLDER = "data"
DATA_FOLDER = "TODO"
def load_json(filename: str):
with open(filename + ".json") as f:

0
utils/ksp_utils.py → hrochobot/utils/ksp_utils.py

19
setup.py

@ -0,0 +1,19 @@
#!/usr/bin/env python3
import setuptools
setuptools.setup(
name='hrochbot',
version='1.0',
description='Discordový robot pro KSP',
packages=['hrochobot', 'hrochobot/cogs', 'hrochobot/utils'],
scripts=[
'bin/hrochobot',
],
include_package_data=True,
zip_safe=False,
install_requires=[
'py-cord',
'requests',
],
)
Loading…
Cancel
Save