A szurubooru discord bot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

44 lines
1.6 KiB

# stdlib
import asyncio
import logging
import logging.config
# external libraries
import discord
from discord.ext import commands
from discord.ext import tasks
logging.basicConfig(level=logging.INFO, filename="boorubot.log", format='[%(asctime)s][%(levelname)s] %(message)s', datefmt='%Y/%m/%d-%I:%M:%S%p')
logging.config.dictConfig({'version': 1, 'disable_existing_loggers': True})
logger = logging.getLogger(__name__)
import retaggr
# same folder
import classes.reverse_search_cog as reverse_search
import classes.szurubooru_manage as szurubooru_manage
import dumbfix
from config import *
# Retagger min ver check
if retaggr.version_info.major <= 2:
if retaggr.version_info.minor < 2:
raise RuntimeError("retaggr is too old to work safely with this bot! Update it!")
bot = commands.Bot(";;")
rsearch = retaggr.ReverseSearch(retaggr.ReverseSearchConfig(**REVERSE_SEARCH_CONFIG))
cog = reverse_search.ReverseSearchCog(bot, rsearch, BOORU_URL, USERNAME, PASSWORD, MONITOR_CHANNEL, SAFE_CHANNEL, SKETCHY_CHANNEL, UNSAFE_CHANNEL, MEME_CHANNEL)
cog2 = szurubooru_manage.SzurubooruManagement(bot, BOORU_URL, USERNAME, PASSWORD)
bot.add_cog(cog)
bot.add_cog(cog2)
@bot.event
async def on_ready():
if not bot.guilds:
app_info = await bot.application_info()
appid = app_info.id
logging.warning(f"Application is not in any guilds. Add the bot to a guild:\n https://discordapp.com/oauth2/authorize?client_id={appid}&scope=bot&permissions=1040")
logging.info("Application has reached on_ready state.")
dumbfix.ignore_aiohttp_ssl_eror(bot.loop)
logging.info("Application has reached post-configuration state.")
bot.run(BOT_TOKEN)