3.0
This commit is contained in:
parent
95af75a5c2
commit
82531f9645
3
.env.example
Normal file
3
.env.example
Normal file
@ -0,0 +1,3 @@
|
||||
BOT_TOKEN=bot_token
|
||||
DB_USERNAME=databaseuser
|
||||
DB_PASSWORD=databasepass
|
||||
22
compose.yaml
Normal file
22
compose.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
services:
|
||||
turdbot:
|
||||
image: "ionburger/turdbot:latest"
|
||||
restart: always
|
||||
container_name: turdbot
|
||||
depends_on:
|
||||
- mongodb
|
||||
environment:
|
||||
- BOT_TOKEN=${BOT_TOKEN}
|
||||
- DB_HOST=mongodb
|
||||
- DB_USERNAME=${DB_USERNAME}
|
||||
- DB_PASSWORD=${DB_PASSWORD}
|
||||
|
||||
mongodb:
|
||||
image: mongo
|
||||
restart: always
|
||||
container_name: mongodb
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME=${DB_USERNAME}
|
||||
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASSWORD}
|
||||
ports:
|
||||
- "27017:27017"
|
||||
21
compose.yaml.prod
Normal file
21
compose.yaml.prod
Normal file
@ -0,0 +1,21 @@
|
||||
services:
|
||||
turdbot:
|
||||
image: "ionburger/turdbot:latest"
|
||||
restart: always
|
||||
container_name: turdbot
|
||||
depends_on:
|
||||
- mongodb
|
||||
environment:
|
||||
- BOT_TOKEN=${BOT_TOKEN}
|
||||
- DB_HOST=mongodb
|
||||
- DB_USERNAME=${DB_USERNAME}
|
||||
- DB_PASSWORD=${DB_PASSWORD}
|
||||
|
||||
mongodb:
|
||||
image: mongo
|
||||
restart: always
|
||||
container_name: mongodb
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME=${DB_USERNAME}
|
||||
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASSWORD}
|
||||
|
||||
6
py/Dockerfile
Normal file
6
py/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
||||
FROM python:3.12-slim
|
||||
RUN mkdir -p /app
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
RUN pip install -r requirements.txt
|
||||
ENTRYPOINT ["python", "-u", "bot.py"]
|
||||
35
py/bot.py
35
py/bot.py
@ -1,15 +1,11 @@
|
||||
import configparser
|
||||
from os import environ as env
|
||||
import discord
|
||||
from discord.ext import bridge
|
||||
import discord
|
||||
import logging
|
||||
from pymongo import MongoClient
|
||||
from bin.storage import storage
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read("config/bot.conf")
|
||||
|
||||
logging.basicConfig(filename="turdbot.log",level=logging.INFO)
|
||||
|
||||
bot = bridge.Bot(
|
||||
help_command=None,
|
||||
@ -20,17 +16,22 @@ bot = bridge.Bot(
|
||||
name="you")
|
||||
)
|
||||
|
||||
bot.load_extension("cogs.reply")
|
||||
bot.load_extension("cogs.counting")
|
||||
|
||||
uri = f"mongodb://{env['DB_USERNAME']}:{env['DB_PASSWORD']}@{env['DB_HOST']}/?authSource=admin"
|
||||
bot.db = MongoClient(uri)["turdbot"]
|
||||
|
||||
@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"]
|
||||
print("Logged in as")
|
||||
print(bot.user.name)
|
||||
print(bot.user.id)
|
||||
print("------")
|
||||
logging.info(f"Logged in as {bot.user} (ID: {bot.user.id})")
|
||||
for guild in bot.guilds:
|
||||
logging.info(f"Added {guild.name} (ID: {guild.id})")
|
||||
storage(guild.id, bot.db).update_guild()
|
||||
|
||||
|
||||
bot.run(config["MAIN"]["token"])
|
||||
bot.run(env["BOT_TOKEN"])
|
||||
@ -1,6 +1,38 @@
|
||||
from discord.ext import bridge
|
||||
from discord.ext import bridge, commands
|
||||
from bin.storage import storage
|
||||
|
||||
class Counting(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
db = storage(message.guild.id, self.bot.db).db
|
||||
count = int(db('counting', 'count'))
|
||||
print(count, message.content[0])
|
||||
|
||||
if message.author.bot or message.channel.id != db('counting', 'channel') or not message.content.isdigit():
|
||||
return
|
||||
|
||||
elif message.author.id == db('counting', 'user'):
|
||||
await message.reply(f"you done fucked up there chief, you cant count twice")
|
||||
|
||||
elif str(count+1) != message.content:
|
||||
await message.reply(f"you done fucked up there chief, count was {count}")
|
||||
|
||||
else:
|
||||
db('counting', 'count', count+1)
|
||||
db('counting', 'user', message.author.id)
|
||||
await message.add_reaction('✅')
|
||||
|
||||
|
||||
@bridge.bridge_command()
|
||||
async def channel(self, ctx):
|
||||
db = storage(ctx.guild.id, self.bot.db).db
|
||||
db('counting', 'channel', ctx.channel.id)
|
||||
await ctx.send("counting channel set")
|
||||
|
||||
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
from discord.ext import bridge, commands
|
||||
import discord
|
||||
from bin.storage import storage
|
||||
|
||||
#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):
|
||||
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:
|
||||
l[msg.id] = attachment.url
|
||||
st.db("test", "test", l)
|
||||
def setup(bot):
|
||||
bot.add_cog(Repost(bot))
|
||||
3
py/requirements.txt
Normal file
3
py/requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
py-cord[audio]
|
||||
pymongo
|
||||
PyNaCl
|
||||
Loading…
Reference in New Issue
Block a user