diff --git a/py/bin/storage.py b/py/bin/storage.py index 52ba341..a3f5163 100644 --- a/py/bin/storage.py +++ b/py/bin/storage.py @@ -1,4 +1,4 @@ -class Storage: +class storage: def __init__(self, serverid, db): self.serverdb = db[str(serverid)] self.defaultdb = db["default"] diff --git a/py/bot.py b/py/bot.py index 9e9901c..10adc30 100644 --- a/py/bot.py +++ b/py/bot.py @@ -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"]) \ No newline at end of file diff --git a/py/cogs/reply.py b/py/cogs/reply.py index 77996e9..892cb3c 100644 --- a/py/cogs/reply.py +++ b/py/cogs/reply.py @@ -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)) \ No newline at end of file diff --git a/py/cogs/repost.py b/py/cogs/repost.py index ced03ef..fa666ee 100644 --- a/py/cogs/repost.py +++ b/py/cogs/repost.py @@ -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)) \ No newline at end of file