clean app.py
This commit is contained in:
parent
9e40377104
commit
c7e3ee2ba8
14
app.py
14
app.py
|
@ -24,17 +24,13 @@ WEBHOOK_PATH = f'/bot{config.token}/'
|
||||||
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}"
|
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}"
|
||||||
|
|
||||||
async def on_startup(dp):
|
async def on_startup(dp):
|
||||||
if not db.get_columns('members'):
|
from utils.notify_start import notify_started_bot, database_is_empty
|
||||||
db.create_tables([Member,Restriction])
|
|
||||||
logging.warning("Member table is empty")
|
|
||||||
await bot.send_message(config.second_group_id, "First launch successful!")
|
|
||||||
await bot.send_message(config.second_group_id, "Member table is empty, run: `!reload`",parse_mode="Markdown")
|
|
||||||
|
|
||||||
elif Member.select().count() == 0:
|
DATABASE_EMPTY = database_is_empty()
|
||||||
await bot.send_message(config.second_group_id, "Member table is empty, run `!reload`",parse_mode="Markdown")
|
if DATABASE_EMPTY:
|
||||||
logging.warning("Member table is empty")
|
await bot.send_message(config.second_group_id,
|
||||||
|
"Member table is empty, run: `!reload`",parse_mode="Markdown")
|
||||||
|
|
||||||
from utils.notify_start import notify_started_bot
|
|
||||||
await notify_started_bot(bot)
|
await notify_started_bot(bot)
|
||||||
|
|
||||||
from utils.default_commands import set_default_commands
|
from utils.default_commands import set_default_commands
|
||||||
|
|
|
@ -1,4 +1,16 @@
|
||||||
import config
|
import config
|
||||||
|
from database import Member, Restriction
|
||||||
|
from database import db
|
||||||
|
|
||||||
|
def database_is_empty():
|
||||||
|
if not db.get_columns("members"):
|
||||||
|
db.create_tables([Member, Restriction])
|
||||||
|
return True
|
||||||
|
|
||||||
|
elif not Member.select().count():
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
async def notify_started_bot(bot):
|
async def notify_started_bot(bot):
|
||||||
await bot.send_message(config.second_group_id,"Bot successfully launched!")
|
await bot.send_message(config.second_group_id,"Bot successfully launched!")
|
||||||
|
|
Reference in New Issue