diff --git a/py/bin/imagematcher.py b/py/bin/imagematcher.py new file mode 100644 index 0000000..e69de29 diff --git a/py/bin/storage.py b/py/bin/storage.py index a365a3c..52ba341 100644 --- a/py/bin/storage.py +++ b/py/bin/storage.py @@ -1,5 +1,3 @@ -import pymongo - class Storage: def __init__(self, serverid, db): self.serverdb = db[str(serverid)] @@ -20,5 +18,4 @@ class Storage: existing_doc[key] = value self.serverdb.replace_one({"module": doc["module"]}, existing_doc) else: - self.serverdb.insert_one(doc) - \ No newline at end of file + self.serverdb.insert_one(doc) \ No newline at end of file diff --git a/py/bot.py b/py/bot.py index 19caddf..9e9901c 100644 --- a/py/bot.py +++ b/py/bot.py @@ -1,12 +1,30 @@ +import configparser import discord +from discord.ext import bridge +import discord +import logging -bot = discord.Bot( - help_command="help", +logging.basicConfig(level=logging.WARNING) + +config = configparser.ConfigParser() +config.read("config/bot.conf") + +bot = bridge.Bot( + help_command=None, command_prefix="!", intents=discord.Intents.all(), activity=discord.Activity( - type=discord.ActivityType.playing, - name="with deez nuts", - ) + type=discord.ActivityType.watching, + name="you") ) -bot.run("OTg2NDA4MjM3Njg5NjMwNzYx.GOWW5z.Engl7UzrUyQkmj0hwQi42U-Z-XQ8CZPuMQRFlU") \ No newline at end of file + +@bot.event +async def on_ready(): + print(f"Logged in as {bot.user} (ID: {bot.user.id})") + bot.load_extension("cogs.reply") + bot.load_extension("cogs.repost") + # bot.load_extension("cogs.counting") + # bot.load_extension("cogs.test") + + +bot.run(config["MAIN"]["token"]) \ No newline at end of file diff --git a/py/cogs/counting.py b/py/cogs/counting.py new file mode 100644 index 0000000..2dbd456 --- /dev/null +++ b/py/cogs/counting.py @@ -0,0 +1,7 @@ +from discord.ext import bridge + + + + +def setup(bot): + bot.add_cog(Counting(bot)) \ No newline at end of file diff --git a/py/cogs/reply.py b/py/cogs/reply.py new file mode 100644 index 0000000..77996e9 --- /dev/null +++ b/py/cogs/reply.py @@ -0,0 +1,12 @@ +from discord.ext import bridge, commands + +class Reply(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @bridge.bridge_command() + async def reply(self, ctx, *args): + await ctx.send(args) + +def setup(bot): + bot.add_cog(Reply(bot)) \ No newline at end of file diff --git a/py/cogs/repost.py b/py/cogs/repost.py new file mode 100644 index 0000000..ced03ef --- /dev/null +++ b/py/cogs/repost.py @@ -0,0 +1,19 @@ +from discord.ext import bridge, commands +import discord +import opencv +from bin.imagematcher import imagematcher + +class Repost(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @bridge.bridge_command() + async def repost(self, ctx): + referenceimgurl = ctx.channel.fetch_message(ctx.message.reference.message_id).attachments[0].url + msgs = await ctx.channel.history(limit=50).flatten() + for msg in msgs: + for attachment in msg.attachments: + if imagematcher(attachment.url, referenceimgurl) < 90: + await ctx.send(attachment.url) +def setup(bot): + bot.add_cog(Repost(bot)) \ No newline at end of file diff --git a/py/config/bot.conf.example b/py/config/bot.conf.example new file mode 100644 index 0000000..e69de29