yed
This commit is contained in:
parent
72bed0925c
commit
95af75a5c2
@ -1,4 +1,4 @@
|
|||||||
class Storage:
|
class storage:
|
||||||
def __init__(self, serverid, db):
|
def __init__(self, serverid, db):
|
||||||
self.serverdb = db[str(serverid)]
|
self.serverdb = db[str(serverid)]
|
||||||
self.defaultdb = db["default"]
|
self.defaultdb = db["default"]
|
||||||
|
|||||||
@ -3,12 +3,14 @@ import discord
|
|||||||
from discord.ext import bridge
|
from discord.ext import bridge
|
||||||
import discord
|
import discord
|
||||||
import logging
|
import logging
|
||||||
|
from pymongo import MongoClient
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read("config/bot.conf")
|
config.read("config/bot.conf")
|
||||||
|
|
||||||
|
|
||||||
bot = bridge.Bot(
|
bot = bridge.Bot(
|
||||||
help_command=None,
|
help_command=None,
|
||||||
command_prefix="!",
|
command_prefix="!",
|
||||||
@ -21,10 +23,14 @@ bot = bridge.Bot(
|
|||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
|
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
|
||||||
|
|
||||||
bot.load_extension("cogs.reply")
|
bot.load_extension("cogs.reply")
|
||||||
bot.load_extension("cogs.repost")
|
bot.load_extension("cogs.repost")
|
||||||
# bot.load_extension("cogs.counting")
|
# bot.load_extension("cogs.counting")
|
||||||
# bot.load_extension("cogs.test")
|
# bot.load_extension("cogs.test")
|
||||||
|
|
||||||
|
|
||||||
|
bot.db = MongoClient(config["DATABASE"]["uri"])["main"]
|
||||||
|
|
||||||
|
|
||||||
bot.run(config["MAIN"]["token"])
|
bot.run(config["MAIN"]["token"])
|
||||||
@ -6,7 +6,7 @@ class Reply(commands.Cog):
|
|||||||
|
|
||||||
@bridge.bridge_command()
|
@bridge.bridge_command()
|
||||||
async def reply(self, ctx, *args):
|
async def reply(self, ctx, *args):
|
||||||
await ctx.send(args)
|
await ctx.send(args[0:])
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Reply(bot))
|
bot.add_cog(Reply(bot))
|
||||||
@ -1,7 +1,9 @@
|
|||||||
from discord.ext import bridge, commands
|
from discord.ext import bridge, commands
|
||||||
import discord
|
import discord
|
||||||
import opencv
|
from bin.storage import storage
|
||||||
from bin.imagematcher import imagematcher
|
|
||||||
|
#import opencv
|
||||||
|
#from bin.imagematcher import imagematcher
|
||||||
|
|
||||||
class Repost(commands.Cog):
|
class Repost(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
@ -9,11 +11,13 @@ class Repost(commands.Cog):
|
|||||||
|
|
||||||
@bridge.bridge_command()
|
@bridge.bridge_command()
|
||||||
async def repost(self, ctx):
|
async def repost(self, ctx):
|
||||||
referenceimgurl = ctx.channel.fetch_message(ctx.message.reference.message_id).attachments[0].url
|
st = storage("test", self.bot.db)
|
||||||
msgs = await ctx.channel.history(limit=50).flatten()
|
#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 msg in msgs:
|
||||||
for attachment in msg.attachments:
|
for attachment in msg.attachments:
|
||||||
if imagematcher(attachment.url, referenceimgurl) < 90:
|
l[msg.id] = attachment.url
|
||||||
await ctx.send(attachment.url)
|
st.db("test", "test", l)
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Repost(bot))
|
bot.add_cog(Repost(bot))
|
||||||
Loading…
Reference in New Issue
Block a user