updated readme and resetted pollmaster files

This commit is contained in:
Hendrik Behme 2019-08-27 12:27:53 +02:00
parent 531a172eb6
commit 04faed2f07
4 changed files with 21 additions and 27 deletions

11
Readme.md Normal file
View File

@ -0,0 +1,11 @@
## Install
Create an Application here: https://discordapp.com/developers/applications and authenticate the Bot.
Copy `.env-dist` to `.env` and fill in the needed information.
Execute `docker-compose up -d --build`.
_See the magic happen_
See pm/readme.md to show the Pollmaster-Readme

View File

@ -19,10 +19,6 @@ services:
# App - Container, where the main application runs # App - Container, where the main application runs
app: app:
restart: always restart: always
volumes:
- ./pm/cogs/poll_controls.py:/data/pm/cogs/poll_controls.py
- ./pm/pollmaster.py:/data/pm/pollmaster.py
- ./pm/essentials/secrets.py:/data/pm/essentials/secrets.py
links: links:
- mongo - mongo
build: build:

View File

@ -50,9 +50,7 @@ class PollControls(commands.Cog):
while True: while True:
try: try:
if not hasattr(self.bot, 'db'): if not hasattr(self.bot, 'db'):
"""await asyncio.sleep(30)""" await asyncio.sleep(30)
logger.info("DB not available yet")
time.sleep(30)
continue continue
query = self.bot.db.polls.find({'active': False, 'activation': {"$not": re.compile("0")}}) query = self.bot.db.polls.find({'active': False, 'activation': {"$not": re.compile("0")}})

View File

@ -13,8 +13,6 @@ from motor.motor_asyncio import AsyncIOMotorClient
from essentials.multi_server import get_pre from essentials.multi_server import get_pre
from essentials.settings import SETTINGS from essentials.settings import SETTINGS
from pprint import pprint
bot_config = { bot_config = {
'command_prefix': get_pre, 'command_prefix': get_pre,
'pm_help': False, 'pm_help': False,
@ -45,9 +43,17 @@ ch.setFormatter(formatter)
logger.addHandler(fh) logger.addHandler(fh)
logger.addHandler(ch) logger.addHandler(ch)
extensions = ['cogs.config', 'cogs.poll_controls', 'cogs.help', 'cogs.db_api', 'cogs.admin']
for ext in extensions:
bot.load_extension(ext)
@bot.event @bot.event
async def on_ready(): async def on_ready():
bot.owner = await bot.fetch_user(SETTINGS.owner_id) bot.owner = await bot.fetch_user(SETTINGS.owner_id)
mongo = AsyncIOMotorClient(SETTINGS.mongo_db)
bot.db = mongo.pollmaster
bot.session = aiohttp.ClientSession() bot.session = aiohttp.ClientSession()
print(bot.db) print(bot.db)
@ -65,7 +71,6 @@ async def on_ready():
except: except:
print("Problem verifying servers.") print("Problem verifying servers.")
logger.error("Problem verifying servers.")
# cache prefixes # cache prefixes
bot.pre = {entry['_id']: entry['prefix'] async for entry in bot.db.config.find({}, {'_id', 'prefix'})} bot.pre = {entry['_id']: entry['prefix'] async for entry in bot.db.config.find({}, {'_id', 'prefix'})}
@ -77,7 +82,6 @@ async def on_ready():
await bot.change_presence(status=discord.Status.online, activity=game) await bot.change_presence(status=discord.Status.online, activity=game)
print("Servers verified. Bot running.") print("Servers verified. Bot running.")
logger.info("Servers verified. Bot running.")
@bot.event @bot.event
async def on_command_error(ctx, e): async def on_command_error(ctx, e):
@ -132,19 +136,4 @@ async def on_guild_join(server):
) )
bot.pre[str(server.id)] = 'pm!' bot.pre[str(server.id)] = 'pm!'
logger.info("Connecting to Mongo DB: " + SETTINGS.mongo_db)
mongo = AsyncIOMotorClient(SETTINGS.mongo_db)
pprint(mongo)
bot.db = mongo.pollmaster
print(bot.db)
pprint(bot.db)
extensions = ['cogs.config', 'cogs.poll_controls', 'cogs.help', 'cogs.db_api', 'cogs.admin']
for ext in extensions:
logger.info("Loading extension " + ext)
bot.load_extension(ext)
pprint(SETTINGS.bot_token)
bot.run(SETTINGS.bot_token) bot.run(SETTINGS.bot_token)