Browse Source

Reduce the number of requirements.

main
Nichole Mattera 10 months ago
parent
commit
454d49317f
  1. 25
      Robocop.py
  2. 6
      cogs/common.py
  3. 5
      requirements.txt

25
Robocop.py

@ -4,17 +4,11 @@ import sys
import logging
import logging.handlers
import traceback
import aiohttp
import config
import discord
from discord.ext import commands
script_name = os.path.basename(__file__).split('.')[0]
# Limit of discord (non-nitro) is 8MB (not MiB)
max_file_size = 1000 * 1000 * 8
backup_count = 3
stdout_handler = logging.StreamHandler(sys.stdout)
log_format = logging.Formatter(
@ -43,7 +37,6 @@ bot = commands.Bot(command_prefix=get_prefix,
bot.log = log
bot.loop = asyncio.get_event_loop()
bot.config = config
bot.script_name = script_name
if __name__ == '__main__':
for extension in initial_extensions:
@ -56,18 +49,14 @@ if __name__ == '__main__':
@bot.event
async def on_ready():
aioh = {"User-Agent": f"{script_name}/1.0'"}
bot.aiosession = aiohttp.ClientSession(headers=aioh)
bot.app_info = await bot.application_info()
bot.botlog_channel = bot.get_channel(config.botlog_channel)
log.info(f'\nLogged in as: {bot.user.name} - '
f'{bot.user.id}\ndpy version: {discord.__version__}\n')
game_name = f"{config.prefixes[0]}help"
# Send "Robocop has started! x has y members!"
guild = bot.botlog_channel.guild
msg = f"{bot.user.name} has started!"
await bot.botlog_channel.send(msg)
activity = discord.Activity(name=game_name,
type=discord.ActivityType.listening)
@ -75,18 +64,6 @@ async def on_ready():
await bot.change_presence(activity=activity)
@bot.event
async def on_command(ctx):
log_text = f"{ctx.message.author} ({ctx.message.author.id}): "\
f"\"{ctx.message.content}\" "
if ctx.guild: # was too long for tertiary if
log_text += f"on \"{ctx.channel.name}\" ({ctx.channel.id}) "\
f"at \"{ctx.guild.name}\" ({ctx.guild.id})"
else:
log_text += f"on DMs ({ctx.channel.id})"
log.info(log_text)
@bot.event
async def on_error(event_method, *args, **kwargs):
log.error(f"Error on {event_method}: {sys.exc_info()}")

6
cogs/common.py

@ -1,10 +1,4 @@
import asyncio
import traceback
import datetime
import humanize
import time
import math
import parsedatetime
from discord.ext.commands import Cog
class Common(Cog):

5
requirements.txt

@ -1,7 +1,2 @@
discord.py
asyncio
python-dateutil
humanize
parsedatetime
aiohttp
gidgethub
Loading…
Cancel
Save