Prepare main branch for v2.0 release
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2021 Peter van Arkel
|
Copyright (c) 2022 - Peter van Arkel
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -1,33 +1,62 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
import typing
|
||||||
|
from datetime import timedelta
|
||||||
|
from discord import User, errors, TextChannel, Forbidden
|
||||||
|
|
||||||
# setup logging
|
# setup logging
|
||||||
log = getLogger(__name__)
|
log = getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
embed = discord.Embed()
|
embed = discord.Embed()
|
||||||
|
|
||||||
|
|
||||||
class Admin(commands.Cog):
|
class Admin(commands.Cog):
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command(name='purge', hidden=True)
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def clear(self, ctx, amount=1):
|
async def purge(self, ctx, amount=1):
|
||||||
await ctx.channel.purge(limit=amount)
|
""" Purge <n> messages from current channel"""
|
||||||
log.warn(f'{ctx.message.author} cleared {amount} messages')
|
await ctx.message.delete()
|
||||||
|
await ctx.channel.purge(limit = amount)
|
||||||
|
log.warn(f'{ctx.message.author} purged {amount} messages')
|
||||||
|
|
||||||
|
@commands.command(name='purge_from', hidden=True)
|
||||||
|
@commands.is_owner()
|
||||||
|
async def purge_from(self, ctx, message_id: int):
|
||||||
|
"""Purge all messages after the given message.id"""
|
||||||
|
try:
|
||||||
|
message = await ctx.channel.fetch_message(message_id)
|
||||||
|
except errors.NotFound:
|
||||||
|
log.warn(f'{ctx.message.author} tried purging {message_id}, but id was not found.')
|
||||||
|
return
|
||||||
|
await ctx.message.delete()
|
||||||
|
await ctx.channel.purge(after=message)
|
||||||
|
log.info(f'{ctx.message.author} purged all messages after {message_id}')
|
||||||
|
return True
|
||||||
|
|
||||||
|
@commands.command(name='purge_user', hidden=True)
|
||||||
|
@commands.is_owner()
|
||||||
|
async def purge_user(self, ctx, user: User, num_minutes: typing.Optional[int] = 5):
|
||||||
|
"""Clear all messages of <user.id> in all channels within the last [n=5] minutes"""
|
||||||
|
after = ctx.message.created_at - timedelta(minutes=num_minutes)
|
||||||
|
|
||||||
|
def check(msg):
|
||||||
|
return msg.author.id == user.id
|
||||||
|
|
||||||
|
for channel in await ctx.guild.fetch_channels():
|
||||||
|
if type(channel) is TextChannel:
|
||||||
|
try:
|
||||||
|
await channel.purge(limit=10*num_minutes, check=check, after=after)
|
||||||
|
log.info(f'{ctx.message.author} purged all messages from {user.id} that were posted within the last {num_minutes}')
|
||||||
|
except Forbidden:
|
||||||
|
continue
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
log.info(f'module active')
|
log.info(f'module active')
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
def setup(bot):
|
await bot.add_cog(Admin(bot))
|
||||||
bot.add_cog(Admin(bot))
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import discord
|
|
||||||
from discord.ext import commands
|
|
||||||
from logging import getLogger
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
|
|
||||||
# setup logging
|
|
||||||
log = getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
e = discord.Embed()
|
|
||||||
|
|
||||||
|
|
||||||
class Flair(commands.Cog):
|
|
||||||
""" The Flair functionality enables the user to setup flair for their profile.
|
|
||||||
|
|
||||||
Currently, the flair-roles available are:
|
|
||||||
- gender pronouns
|
|
||||||
- willingness to join mature discussions
|
|
||||||
- whether or not they are open for DMs
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, bot):
|
|
||||||
self.bot = bot
|
|
||||||
self.msg1 = ['✅', '❌', '❔']
|
|
||||||
|
|
||||||
@commands.command()
|
|
||||||
async def flair(self, ctx):
|
|
||||||
msg1 = (
|
|
||||||
f'Welkom bij de flair-wizard! Gebruik onderstaande opties om verder te gaan. \n\n'
|
|
||||||
f'Druk op ✅ als je verder wil gaan met de wizard.\n'
|
|
||||||
f'Als je niet je flair opnieuw wilt instellen, druk dan op ❌.\n'
|
|
||||||
f'Gebruik ❔ als je wil weten hoe je via een tekstcommando alles kan instellen.\n\n'
|
|
||||||
)
|
|
||||||
dm = await ctx.author.send(msg1)
|
|
||||||
log.info(f'{ctx.author} started the flair wizard')
|
|
||||||
for emoji in self.msg1:
|
|
||||||
await dm.add_reaction(emoji)
|
|
||||||
|
|
||||||
|
|
||||||
@commands.Cog.listener()
|
|
||||||
async def on_ready(self):
|
|
||||||
log.info(f'module active')
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
bot.add_cog(Flair(bot))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# numbers_reactions = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣']
|
|
||||||
@@ -44,5 +44,5 @@ class Games(commands.Cog):
|
|||||||
log.info(f'module active')
|
log.info(f'module active')
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Games(bot))
|
await bot.add_cog(Games(bot))
|
||||||
@@ -63,5 +63,5 @@ class Gif(commands.Cog):
|
|||||||
log.info(f'module active')
|
log.info(f'module active')
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Gif(bot))
|
await bot.add_cog(Gif(bot))
|
||||||
@@ -32,6 +32,6 @@ class Links(commands.Cog):
|
|||||||
log.info(f'module active')
|
log.info(f'module active')
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Links(bot))
|
await bot.add_cog(Links(bot))
|
||||||
|
|
||||||
|
|||||||
@@ -33,5 +33,5 @@ class Misc(commands.Cog):
|
|||||||
log.info(f'module active')
|
log.info(f'module active')
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Misc(bot))
|
await bot.add_cog(Misc(bot))
|
||||||
@@ -22,5 +22,5 @@ class Moderator(commands.Cog):
|
|||||||
log.info(f'module active')
|
log.info(f'module active')
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Moderator(bot))
|
await bot.add_cog(Moderator(bot))
|
||||||
28
jeeves.py
28
jeeves.py
@@ -7,43 +7,44 @@ import os
|
|||||||
import log
|
import log
|
||||||
import logging.config
|
import logging.config
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
# setup root logger handlers
|
# setup root logger handlers
|
||||||
logging.config.dictConfig(log.LOGGING)
|
logging.config.dictConfig(log.LOGGING)
|
||||||
|
|
||||||
# setup logging
|
# setup logging
|
||||||
log = getLogger(__name__)
|
log = getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# setup discord.py bot
|
# setup discord.py bot
|
||||||
intents = discord.Intents().all()
|
intents = discord.Intents().all()
|
||||||
bot = commands.Bot(command_prefix='!', intents=intents)
|
bot = commands.Bot(command_prefix='!', intents=intents)
|
||||||
e = discord.Embed()
|
e = discord.Embed()
|
||||||
|
|
||||||
|
@bot.command(name='load', hidden=True)
|
||||||
@bot.command()
|
|
||||||
@commands.has_permissions(administrator=True)
|
@commands.has_permissions(administrator=True)
|
||||||
async def load(ctx, extension):
|
async def load(ctx, extension):
|
||||||
bot.load_extension(f'cogs.{extension}')
|
bot.load_extension(f'cogs.{extension}')
|
||||||
log.info(f'{ctx.message.author} loaded the {extension} module')
|
log.info(f'{ctx.message.author} loaded the {extension} module')
|
||||||
|
|
||||||
|
|
||||||
@bot.command()
|
@bot.command(name='unload', hidden=True)
|
||||||
@commands.has_permissions(administrator=True)
|
@commands.has_permissions(administrator=True)
|
||||||
async def unload(ctx, extension):
|
async def unload(ctx, extension):
|
||||||
bot.unload_extension(f'cogs.{extension}')
|
bot.unload_extension(f'cogs.{extension}')
|
||||||
log.info(f'{ctx.message.author} unloaded the {extension} module')
|
log.info(f'{ctx.message.author} unloaded the {extension} module')
|
||||||
|
|
||||||
|
|
||||||
@bot.command()
|
@bot.command(name='reload', hidden=True)
|
||||||
@commands.has_permissions(administrator=True)
|
@commands.has_permissions(administrator=True)
|
||||||
async def reload(ctx, extension):
|
async def reload(ctx, extension):
|
||||||
bot.unload_extension(f'cogs.{extension}')
|
bot.unload_extension(f'cogs.{extension}')
|
||||||
bot.load_extension(f'cogs.{extension}')
|
bot.load_extension(f'cogs.{extension}')
|
||||||
log.info(f'{ctx.message.author} reloaded the {extension} module')
|
log.info(f'{ctx.message.author} reloaded the {extension} module')
|
||||||
|
|
||||||
|
async def load_extensions():
|
||||||
|
for filename in os.listdir('./cogs'):
|
||||||
|
if filename.endswith('.py'):
|
||||||
|
await bot.load_extension(f'cogs.{filename[:-3]}')
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
@@ -51,12 +52,9 @@ async def on_ready():
|
|||||||
activity = discord.Activity(name='!help', type=discord.ActivityType.listening)
|
activity = discord.Activity(name='!help', type=discord.ActivityType.listening)
|
||||||
await bot.change_presence(activity=activity)
|
await bot.change_presence(activity=activity)
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
async with bot:
|
||||||
|
await load_extensions()
|
||||||
|
await bot.start(env.TOKEN)
|
||||||
|
|
||||||
for filename in os.listdir('./cogs'):
|
asyncio.run(main())
|
||||||
if filename.endswith('.py'):
|
|
||||||
bot.load_extension(f'cogs.{filename[:-3]}')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
bot.run(env.TOKEN)
|
|
||||||
|
|
||||||
25
jeevesbot/env.py
Normal file
25
jeevesbot/env.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
### bot settings
|
||||||
|
# TOKEN = 'ODE5NjMyNDg1MjU5ODA0NzU0.YEpcPA.M-zMGu3BT4QEm9HYKwgiMX3ssEk' #LIVE
|
||||||
|
TOKEN = 'OTI3NTYyNTIwMTE2NDczODk2.GaZvW-.kmcKCSVrL7Ain4bBufJyZtSSS3Z6rSx7l-cTR0' # TEST
|
||||||
|
|
||||||
|
### channels
|
||||||
|
# GIFCHANNELS = [724331671020765247,729667183126511617,863879394233942016] #LIVE
|
||||||
|
GIFCHANNELS = [] #TEST
|
||||||
|
FLAIR_CHANNEL = 873576604419387413
|
||||||
|
|
||||||
|
|
||||||
|
### roles
|
||||||
|
ADMIN_ROLE = 'administrator'
|
||||||
|
BINGOROLE = 'babbelbingo'
|
||||||
|
|
||||||
|
|
||||||
|
# 863879394233942016 #overflow-lounge @ LP
|
||||||
|
# 724331671020765247 #lounge @ LP
|
||||||
|
# 729667183126511617 #vraag-van-de-dag @ LP
|
||||||
|
|
||||||
|
# 749399756752814105 #general @ TEST
|
||||||
|
# 776789540978556948 #guest @ TEST
|
||||||
|
|
||||||
|
# 873576604419387413 #flair @ TEST
|
||||||
12
jeevesbot/secret.json
Normal file
12
jeevesbot/secret.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"type": "service_account",
|
||||||
|
"project_id": "drive-pull-300915",
|
||||||
|
"private_key_id": "7d615dce3c433ae5d3c8553aa823629c2fc4d4f3",
|
||||||
|
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDmxvsQLYTZCNIc\nkjRUW+asE/mMeXVI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wFkgGKH4zdqpBXcqfbtC+IjD6e3TpAFbcm7LWfY2\nHinPjBdxHlysiJy6xMXUfLFLZuZJIvXH4RVrrrBcKvpuyc9GBiXBEiL/WbxI0enl\npRIkZ6Nbu9UUtA8TekS3HmsFvKGW1YuQ8XsCDG6uJeOWpAIhuZgtqVYVAoGAOPqS\nP4Q8XMByRU+vFSC1x/JkDrH78tNIxVJ4G4HMOjxoyGs4A9D0cR0mBIIm1dS7bmff\nm0VuYNlv6wYMeHfXfD7VoTmIscjdOXXgF/grq5zg7wOnEvkbF528bqRCEXvQCyqt\nod6akCDXun4dDoqf6kE2n5Pzfu6vqNIolxt8kpECgYEAmlwmccOtFDabchU5rxZJ\ngtqW/w1o86+NQE4o6Oq217YXY68PWoc+UgT2F6R5f6fJ3g8w6/1x2NGHMcte6E9/\n8rJT1L/P7dpdOzYWsN3BWlRhc0ICMslj4Aw7FnA+CL1YWSIp4SML/d6SjHBGkt+l\nVLZ4mr7mDtwPZ883nWw56po=\n-----END PRIVATE KEY-----\n",
|
||||||
|
"client_email": "drive-pull@drive-pull-300915.iam.gserviceaccount.com",
|
||||||
|
"client_id": "103799335310944603536",
|
||||||
|
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
"token_uri": "https://oauth2.googleapis.com/token",
|
||||||
|
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||||
|
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/drive-pull%40drive-pull-300915.iam.gserviceaccount.com"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user