This commit is contained in:
ionburger 2023-12-04 13:51:43 -07:00
parent da9224a9fa
commit 72bed0925c
7 changed files with 63 additions and 10 deletions

0
py/bin/imagematcher.py Normal file
View File

View File

@ -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)
self.serverdb.insert_one(doc)

View File

@ -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")
@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"])

7
py/cogs/counting.py Normal file
View File

@ -0,0 +1,7 @@
from discord.ext import bridge
def setup(bot):
bot.add_cog(Counting(bot))

12
py/cogs/reply.py Normal file
View File

@ -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))

19
py/cogs/repost.py Normal file
View File

@ -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))

View File