2017-09-24 14:09:02 -04:00
|
|
|
import asyncio
|
2017-10-11 02:57:17 -04:00
|
|
|
import datetime as dt
|
2017-10-12 22:28:16 -04:00
|
|
|
import json
|
|
|
|
import logging
|
2017-10-02 17:29:39 -04:00
|
|
|
import os
|
|
|
|
import subprocess
|
2017-10-11 02:57:17 -04:00
|
|
|
import sys
|
2017-10-12 22:28:16 -04:00
|
|
|
import traceback as tb
|
|
|
|
|
|
|
|
import aiohttp as aio
|
|
|
|
import discord as d
|
2017-09-24 14:09:02 -04:00
|
|
|
from discord import utils
|
|
|
|
from discord.ext import commands
|
2017-10-12 22:28:16 -04:00
|
|
|
|
|
|
|
from cogs import booru, info, management, owner, tools
|
2017-09-24 14:09:02 -04:00
|
|
|
from misc import exceptions as exc
|
2017-10-12 22:28:16 -04:00
|
|
|
from misc import checks
|
2017-10-11 02:57:17 -04:00
|
|
|
from utils import utils as u
|
2017-09-24 14:09:02 -04:00
|
|
|
|
2017-10-11 02:57:17 -04:00
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
|
|
print('PID {}'.format(os.getpid()))
|
|
|
|
|
2017-10-13 23:38:58 -04:00
|
|
|
bot = commands.Bot(command_prefix=u.config['prefix'], description='Experimental booru bot')
|
2017-10-12 22:28:16 -04:00
|
|
|
|
|
|
|
|
2017-10-13 23:38:58 -04:00
|
|
|
# Send and print ready message to #testing and console after logon
|
2017-09-24 11:05:28 -04:00
|
|
|
@bot.event
|
|
|
|
async def on_ready():
|
2017-10-11 02:57:17 -04:00
|
|
|
bot.add_cog(tools.Utils(bot))
|
2017-10-13 23:38:58 -04:00
|
|
|
bot.add_cog(owner.Bot(bot))
|
2017-10-11 02:57:17 -04:00
|
|
|
bot.add_cog(owner.Tools(bot))
|
|
|
|
bot.add_cog(management.Administration(bot))
|
|
|
|
bot.add_cog(info.Info(bot))
|
|
|
|
bot.add_cog(booru.MsG(bot))
|
|
|
|
|
2017-10-12 22:28:16 -04:00
|
|
|
u.session = aio.ClientSession(loop=bot.loop)
|
|
|
|
|
2017-10-11 02:57:17 -04:00
|
|
|
# bot.loop.create_task(u.clear(booru.temp_urls, 30*60))
|
|
|
|
|
2017-10-13 23:38:58 -04:00
|
|
|
if isinstance(bot.get_channel(u.config['startup_channel']), d.TextChannel):
|
|
|
|
await bot.get_channel(u.config['startup_channel']).send('**Started.** ☀️')
|
2017-10-11 02:57:17 -04:00
|
|
|
print('CONNECTED')
|
|
|
|
print(bot.user.name)
|
2017-09-24 11:05:28 -04:00
|
|
|
print('-------')
|
|
|
|
|
2017-10-12 22:28:16 -04:00
|
|
|
|
|
|
|
@bot.event
|
|
|
|
async def on_command_error(ctx, error):
|
2017-10-13 21:51:38 -04:00
|
|
|
if not isinstance(error, commands.errors.CommandNotFound):
|
|
|
|
print(error)
|
|
|
|
await ctx.send('{}\n```\n{}```'.format(exc.base, error))
|
2017-10-12 22:28:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
async def on_reaction_add(r, u):
|
2017-10-13 21:51:38 -04:00
|
|
|
pass
|
2017-10-12 22:28:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
async def on_reaction_remove(r, u):
|
2017-10-13 21:51:38 -04:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
async def reaction_add(r, u):
|
|
|
|
bot.add_listener(on_reaction_add)
|
|
|
|
print('Reacted')
|
|
|
|
bot.remove_listener(on_reaction_remove)
|
|
|
|
|
|
|
|
|
|
|
|
async def reaction_remove(r, u):
|
|
|
|
bot.add_listener(on_reaction_remove)
|
2017-10-12 22:28:16 -04:00
|
|
|
print('Removed')
|
2017-10-13 21:51:38 -04:00
|
|
|
bot.remove_listener(on_reaction_remove)
|
2017-10-12 22:28:16 -04:00
|
|
|
|
2017-09-24 11:05:28 -04:00
|
|
|
|
2017-10-11 02:57:17 -04:00
|
|
|
@bot.command(name=',test', hidden=True)
|
2017-09-25 15:31:51 -04:00
|
|
|
@commands.is_owner()
|
2017-09-24 11:05:28 -04:00
|
|
|
@checks.del_ctx()
|
|
|
|
async def test(ctx):
|
2017-10-12 22:28:16 -04:00
|
|
|
test = await ctx.send('Test')
|
|
|
|
await test.add_reaction('✅')
|
|
|
|
bot.add_listener(on_reaction_add)
|
|
|
|
bot.add_listener(on_reaction_remove)
|
2017-09-24 11:05:28 -04:00
|
|
|
|
2017-10-13 23:38:58 -04:00
|
|
|
bot.run(u.config['token'])
|