This commit is contained in:
ionburger 2023-12-14 18:47:29 -07:00
parent 72bed0925c
commit 95af75a5c2
4 changed files with 18 additions and 8 deletions

View File

@ -1,4 +1,4 @@
class Storage:
class storage:
def __init__(self, serverid, db):
self.serverdb = db[str(serverid)]
self.defaultdb = db["default"]

View File

@ -3,12 +3,14 @@ import discord
from discord.ext import bridge
import discord
import logging
from pymongo import MongoClient
logging.basicConfig(level=logging.WARNING)
config = configparser.ConfigParser()
config.read("config/bot.conf")
bot = bridge.Bot(
help_command=None,
command_prefix="!",
@ -21,10 +23,14 @@ bot = bridge.Bot(
@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.db = MongoClient(config["DATABASE"]["uri"])["main"]
bot.run(config["MAIN"]["token"])

View File

@ -6,7 +6,7 @@ class Reply(commands.Cog):
@bridge.bridge_command()
async def reply(self, ctx, *args):
await ctx.send(args)
await ctx.send(args[0:])
def setup(bot):
bot.add_cog(Reply(bot))

View File

@ -1,7 +1,9 @@
from discord.ext import bridge, commands
import discord
import opencv
from bin.imagematcher import imagematcher
from bin.storage import storage
#import opencv
#from bin.imagematcher import imagematcher
class Repost(commands.Cog):
def __init__(self, bot):
@ -9,11 +11,13 @@ class Repost(commands.Cog):
@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()
st = storage("test", self.bot.db)
#referenceimgurl = ctx.channel.fetch_message(ctx.message.reference.message_id).attachments[0].url
msgs = await ctx.channel.history(limit=100).flatten()
l = {}
for msg in msgs:
for attachment in msg.attachments:
if imagematcher(attachment.url, referenceimgurl) < 90:
await ctx.send(attachment.url)
l[msg.id] = attachment.url
st.db("test", "test", l)
def setup(bot):
bot.add_cog(Repost(bot))