stable
This commit is contained in:
parent
229669d557
commit
0823552a2d
@ -2,9 +2,9 @@ class storage:
|
|||||||
def __init__(self, server_id, db):
|
def __init__(self, server_id, db):
|
||||||
self.server_id = str(server_id)
|
self.server_id = str(server_id)
|
||||||
self.db = db
|
self.db = db
|
||||||
self.collection = db['turdbot'] # Replace with your actual collection name
|
self.collection = db['turdbot']
|
||||||
|
|
||||||
async def db(self, module, key=None, value=None):
|
async def store(self, module, key=None, value=None):
|
||||||
document = await self.collection.find_one({"server_id": self.server_id})
|
document = await self.collection.find_one({"server_id": self.server_id})
|
||||||
|
|
||||||
if not document:
|
if not document:
|
||||||
|
|||||||
2
bot.py
2
bot.py
@ -16,6 +16,7 @@ bot = bridge.Bot(
|
|||||||
bot.load_extension("cogs.triggers")
|
bot.load_extension("cogs.triggers")
|
||||||
bot.load_extension("cogs.counting")
|
bot.load_extension("cogs.counting")
|
||||||
bot.load_extension("cogs.settings")
|
bot.load_extension("cogs.settings")
|
||||||
|
bot.load_extension("cogs.misc")
|
||||||
|
|
||||||
uri = f"mongodb://{env['DB_USERNAME']}:{env['DB_PASSWORD']}@{env['DB_HOST']}/?authSource=admin"
|
uri = f"mongodb://{env['DB_USERNAME']}:{env['DB_PASSWORD']}@{env['DB_HOST']}/?authSource=admin"
|
||||||
bot.db = MongoClient(uri)["turdbot"]
|
bot.db = MongoClient(uri)["turdbot"]
|
||||||
@ -27,6 +28,7 @@ async def on_ready():
|
|||||||
print("Logged in as")
|
print("Logged in as")
|
||||||
print(bot.user.name)
|
print(bot.user.name)
|
||||||
print(bot.user.id)
|
print(bot.user.id)
|
||||||
|
print(bot.version)
|
||||||
print("------")
|
print("------")
|
||||||
|
|
||||||
bot.run(env["BOT_TOKEN"])
|
bot.run(env["BOT_TOKEN"])
|
||||||
@ -7,34 +7,34 @@ class Counting(commands.Cog):
|
|||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
db = storage(message.guild.id, self.bot.db).db
|
store = storage(message.guild.id, self.bot.db).store
|
||||||
count = int(db('counting', 'count') or 0)
|
count = int(await store('counting', 'count') or 0)
|
||||||
|
|
||||||
if message.author.bot or message.channel.id != db('counting', 'channel') or not message.content.isdigit():
|
if message.author.bot or message.channel.id != await store('counting', 'channel') or not message.content.isdigit():
|
||||||
return
|
return
|
||||||
|
|
||||||
elif message.author.id == db('counting', 'user'):
|
elif message.author.id == await store('counting', 'user'):
|
||||||
await message.reply(f"you done fucked up there chief, you cant count twice")
|
await message.reply(f"you done fucked up there chief, you cant count twice")
|
||||||
|
|
||||||
elif str(count+1) != message.content:
|
elif str(count+1) != message.content:
|
||||||
await message.reply(f"you done fucked up there chief, count was {count}")
|
await message.reply(f"you done fucked up there chief, count was {count}")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
db('counting', 'count', count+1)
|
await store('counting', 'count', count+1)
|
||||||
db('counting', 'user', message.author.id)
|
await store('counting', 'user', message.author.id)
|
||||||
await message.add_reaction('✅')
|
await message.add_reaction('✅')
|
||||||
|
|
||||||
|
|
||||||
@bridge.bridge_command()
|
@bridge.bridge_command()
|
||||||
async def channel(self, ctx):
|
async def channel(self, ctx):
|
||||||
db = storage(ctx.guild.id, self.bot.db).db
|
store = storage(ctx.guild.id, self.bot.db).store
|
||||||
db('counting', 'channel', ctx.channel.id)
|
await store('counting', 'channel', ctx.channel.id)
|
||||||
await ctx.send(f"counting channel set to {db('counting', 'channel')}")
|
await ctx.send(f"counting channel set to {store('counting', 'channel')}")
|
||||||
|
|
||||||
@bridge.bridge_command()
|
@bridge.bridge_command()
|
||||||
async def setcount(self, ctx, args):
|
async def setcount(self, ctx, args):
|
||||||
db = storage(ctx.guild.id, self.bot.db).db
|
store = storage(ctx.guild.id, self.bot.store).store
|
||||||
db('counting', 'count', args)
|
await store('counting', 'count', args)
|
||||||
await ctx.send(f"count set to {args}")
|
await ctx.send(f"count set to {args}")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,4 +11,8 @@ class Misc(commands.Cog):
|
|||||||
|
|
||||||
@bridge.bridge_command()
|
@bridge.bridge_command()
|
||||||
async def version(self, ctx):
|
async def version(self, ctx):
|
||||||
await ctx.send(self.bot.version)
|
await ctx.send(self.bot.version)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(Misc(bot))
|
||||||
@ -9,11 +9,11 @@ class Triggers(commands.Cog):
|
|||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
return
|
return
|
||||||
db = storage(message.guild.id, self.bot.db).db
|
store = storage(message.guild.id, self.bot.db).store
|
||||||
if db('triggers', 'enabled'):
|
if await store('triggers', 'enabled') == "True":
|
||||||
for trigger in db('triggers', 'triggers'):
|
for trigger in await store('triggers', 'triggers'):
|
||||||
if trigger.lower() in message.content.lower():
|
if trigger.lower() in message.content.lower():
|
||||||
await message.reply(db('triggers', 'response'))
|
await message.reply(store('triggers', 'response'))
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Triggers(bot))
|
bot.add_cog(Triggers(bot))
|
||||||
39
compose/compose-dev.yaml
Normal file
39
compose/compose-dev.yaml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
services:
|
||||||
|
turdbot:
|
||||||
|
image: ionburger/turdbot
|
||||||
|
restart: always
|
||||||
|
container_name: turdbot
|
||||||
|
depends_on:
|
||||||
|
- mongodb
|
||||||
|
environment:
|
||||||
|
- BOT_TOKEN=${BOT_TOKEN}
|
||||||
|
- DB_HOST=mongodb
|
||||||
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
|
- DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
volumes:
|
||||||
|
- ../:/app
|
||||||
|
|
||||||
|
flask:
|
||||||
|
image: ionburger/turdweb
|
||||||
|
restart: always
|
||||||
|
container_name: turdweb
|
||||||
|
depends_on:
|
||||||
|
- mongodb
|
||||||
|
environment:
|
||||||
|
- DB_HOST=mongodb
|
||||||
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
|
- DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- "5005:5005"
|
||||||
|
|
||||||
|
mongodb:
|
||||||
|
image: mongo
|
||||||
|
restart: always
|
||||||
|
container_name: mongodb
|
||||||
|
environment:
|
||||||
|
- MONGO_INITDB_ROOT_USERNAME=${DB_USERNAME}
|
||||||
|
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- "27017:27017"
|
||||||
|
volumes:
|
||||||
|
- ${DB_LOCATION}:/data/db
|
||||||
Loading…
Reference in New Issue
Block a user