removed legacy
This commit is contained in:
parent
0903921d9b
commit
39eba04459
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 404 KiB |
@ -1,18 +0,0 @@
|
||||
<!--
|
||||
# Copyright (c) 2022, Ian Burgess
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the GPLv3 license. A copy of this license can be found in the LICENSE file in the root directory of this source tree.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Turdbot Landing</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href=""></a>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,26 +0,0 @@
|
||||
class Config:
|
||||
def __init__(self, serverid,db):
|
||||
self.serverid = str(serverid)
|
||||
self.db = db[str(serverid)]
|
||||
self.default = db['default']
|
||||
|
||||
def read(self, module, key):
|
||||
return self.db.find_one({'module': module})[key]
|
||||
|
||||
def write(self, module, key, value):
|
||||
self.db.update_one({'module': str(module)}, {'$set': {str(key): str(value)}}, upsert=True)
|
||||
return True
|
||||
|
||||
def updateguild(self):
|
||||
for doc in self.default.find():
|
||||
existing_doc = self.db.find_one({"module": doc["module"]})
|
||||
if existing_doc:
|
||||
for key, value in doc.items():
|
||||
if key not in existing_doc:
|
||||
existing_doc[key] = value
|
||||
self.db.replace_one({"module": doc["module"]}, existing_doc)
|
||||
else:
|
||||
self.db.insert_one(doc)
|
||||
|
||||
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
from py.bin.old import storage
|
||||
import os
|
||||
import shutil
|
||||
import wget
|
||||
import sys
|
||||
|
||||
config.read("config/config.conf")
|
||||
if config["config"]["autoupdate"] == "true":
|
||||
versionl = version.local()
|
||||
versionr = version.remote()
|
||||
if ".".join(versionl)<".".join(versionr):
|
||||
print("outdated version",versionl,"<",versionr)
|
||||
print("autoupdate is enabled, attempting to update")
|
||||
wget.download("https://github.com/ionburger/turdbot/archive/refs/tags/"+versionr+".zip",out = "turdbottmp.zip")
|
||||
shutil.unpack_archive("turdbottmp.zip","turdbottmp")
|
||||
for file in os.listdir("turdbottmp/turdbot-"+versionr+"/py/"):
|
||||
if file.endswith(".py"):
|
||||
shutil.move("turdbottmp/turdbot-"+versionr+"/py/"+file,file)
|
||||
with open("VERSION","w") as file:
|
||||
file.write(versionr)
|
||||
shutil.rmtree("turdbottmp")
|
||||
os.remove("turdbottmp.zip")
|
||||
os.chdir(randir)
|
||||
os.execl(sys.executable, sys.executable, *sys.argv)
|
||||
update = True
|
||||
else:
|
||||
print("running latest version of turdbot",versionl)
|
||||
else:
|
||||
print("autoupdate disabled")
|
||||
@ -1,10 +0,0 @@
|
||||
import subprocess
|
||||
|
||||
def remote():
|
||||
try:
|
||||
process = subprocess.Popen(["lastversion", "ionburger/turdbot"],stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
return (process.communicate()[0]).strip("\n")
|
||||
except:
|
||||
return 0
|
||||
def local():
|
||||
return open("config/VERSION","r").read().strip("\n")
|
||||
@ -1,41 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import bridge, tasks
|
||||
from pymongo import MongoClient
|
||||
import logging
|
||||
import argparse
|
||||
import configparser
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
#setup
|
||||
intents = discord.Intents.all()
|
||||
bot = bridge.Bot(intents=intents,command_prefix=".")
|
||||
config = configparser.ConfigParser()
|
||||
config.read("config/config.conf")
|
||||
bot.config = config
|
||||
bot.db = MongoClient(config["mongodb"]["host"],int(config["mongodb"]["port"]),username=config["mongodb"]["username"],password=config["mongodb"]["password"])["dev"]
|
||||
bot.version = "2.0.0"
|
||||
bot.load_extension("cogs.counting")
|
||||
bot.load_extension("cogs.misc")
|
||||
bot.load_extension("cogs.triggers")
|
||||
bot.load_extension("cogs.dad")
|
||||
bot.load_extension("cogs.voice")
|
||||
#bot.load_extension("cogs.quotequeue")
|
||||
|
||||
|
||||
#logging
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-d","--debug", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(levelname)s %(message)s',filename='logs/bot.log',filemode='w')
|
||||
|
||||
|
||||
else:
|
||||
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(levelname)s %(message)s',filename='logs/bot.log',
|
||||
filemode='w')
|
||||
|
||||
|
||||
bot.run(config["config"]["token"])
|
||||
@ -1,11 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import bridge, commands
|
||||
import openai
|
||||
|
||||
class Askgpt(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@bridge.bridge_command()
|
||||
async def askgpt(self, ctx, *, message):
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from bin.storage import Config
|
||||
|
||||
class Counting(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
st = Config(str(message.guild.id),self.bot.db)
|
||||
if message.author.bot == True or st.read("counting","enabled") == "false" or str(message.channel.id) != st.read("counting","countingchannel",) or not message.content.isnumeric():
|
||||
return
|
||||
|
||||
if int(message.content) == int(st.read("counting","countingcount"))+1 and str(message.author) != st.read("counting","countinguser",):
|
||||
st.write("counting","countingcount",message.content)
|
||||
st.write("counting","countinguser",message.author)
|
||||
elif int(message.content) == int(st.read("counting","countingcount"))+1 and str(message.author) == st.read("counting","countinguser",):
|
||||
await message.channel.send("A user cannot count twice in a row, counting reset to 1")
|
||||
st.write("counting","countingcount",0)
|
||||
st.write("counting","countinguser","None")
|
||||
elif int(message.content) != int(st.read("counting","countingcount"))+1:
|
||||
await message.channel.send("Wrong number, counting reset to 1")
|
||||
st.write("counting","countingcount",0)
|
||||
st.write("counting","countinguser","None")
|
||||
|
||||
def setup(bot):
|
||||
"""
|
||||
Adds the Counting cog to the bot instance.
|
||||
|
||||
Args:
|
||||
bot (discord.ext.commands.Bot): The bot instance.
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
bot.add_cog(Counting(bot))
|
||||
@ -1,24 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from bin.storage import Config
|
||||
|
||||
class Dad(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
st = Config(str(message.guild.id),self.bot.db)
|
||||
if message.author.bot == True or st.read("dad","enabled") == "false":
|
||||
return
|
||||
msg = message.content.split(" ")
|
||||
for i in range(len(msg)):
|
||||
if msg[i].lower() == "i'm" or msg[i].lower() == "im":
|
||||
await message.channel.send(f"Hi {msg[i+1]}, I'm Dad")
|
||||
return
|
||||
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Dad(bot))
|
||||
@ -1,56 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from bin.storage import Config
|
||||
|
||||
class Misc(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_ready(self):
|
||||
print("""
|
||||
_________ _______ ______ ______ _______ _________
|
||||
\__ __/|\ /|( ____ )( __ \ ( ___ \ ( ___ )\__ __/
|
||||
) ( | ) ( || ( )|| ( \ )| ( ) )| ( ) | ) (
|
||||
| | | | | || (____)|| | ) || (__/ / | | | | | |
|
||||
| | | | | || __)| | | || __ ( | | | | | |
|
||||
| | | | | || (\ ( | | ) || ( \ \ | | | | | |
|
||||
| | | (___) || ) \ \__| (__/ )| )___) )| (___) | | |
|
||||
)_( (_______)|/ \__/(______/ |/ \___/ (_______) )_(
|
||||
|
||||
""")
|
||||
print(f"Logged in as {self.bot.user}\nPycord version {discord.__version__}\nTurdbot version {self.bot.version}\n")
|
||||
for guild in self.bot.guilds:
|
||||
st = Config(guild.id,self.bot.db)
|
||||
st.updateguild()
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_guild_join(self, guild):
|
||||
st = Config(guild.id,self.bot.db)
|
||||
st.updateguild()
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
st = Config(message.guild.id,self.bot.db)
|
||||
if message.author.bot == True and st.read("misc","replytobot") == "false":
|
||||
return
|
||||
if str(message.content) == ("r"):
|
||||
self.bot.reload_extension("cogs.misc")
|
||||
self.bot.reload_extension("cogs.triggers")
|
||||
self.bot.reload_extension("cogs.counting")
|
||||
#self.bot.reload_extension("cogs.quotequeue")
|
||||
self.bot.reload_extension("cogs.voice")
|
||||
st = Config(message.guild.id,self.bot.db)
|
||||
st.updateguild()
|
||||
await message.channel.send("r")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Misc(bot))
|
||||
@ -1,29 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import commands, tasks
|
||||
|
||||
import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from bin.storage import Config
|
||||
|
||||
times = [datetime.time(12,0,tzinfo=ZoneInfo("America/Denver"))]
|
||||
|
||||
class Quotequeue(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.db = bot.db
|
||||
self.quotetime.start()
|
||||
print(self.quotetime.next_iteration)
|
||||
|
||||
@tasks.loop(time=times)
|
||||
async def quotetime(self):
|
||||
channel = self.bot.get_channel(1004178748205187086)
|
||||
await channel.send("test")
|
||||
|
||||
@quotetime.before_loop
|
||||
async def before_quotetime(self):
|
||||
await self.bot.wait_until_ready()
|
||||
print(self.quotetime.next_iteration)
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Quotequeue(bot))
|
||||
@ -1,28 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import random
|
||||
from bin.storage import Config
|
||||
|
||||
class Triggers(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
st = Config(message.guild.id,self.bot.db)
|
||||
if message.author.bot == True and st.read("misc","replytobot") == "false" or st.read("triggers","enabled") == "false" or str(message.channel.id) in st.read("triggers","channelblacklist").split("."):
|
||||
return
|
||||
dict = st.read("triggers","triggers")
|
||||
for k,v in dict.items():
|
||||
if v["mode"] == "lax":
|
||||
if k in message.content:
|
||||
await message.channel.send(random.choice(v["replys"].split("/./")))
|
||||
elif v["mode"] == "normal":
|
||||
if k in message.content.split(" "):
|
||||
await message.channel.send(random.choice(v["replys"].split("/./")))
|
||||
elif v["mode"] == "strict":
|
||||
if k == str(message.content):
|
||||
await message.channel.send(random.choice(v["replys"].split("/./")))
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Triggers(bot))
|
||||
@ -1,121 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import bridge, commands
|
||||
import wavelink
|
||||
from bin.storage import Config
|
||||
|
||||
class Voice(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.queue = wavelink.Queue()
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_ready(self):
|
||||
await wavelink.NodePool.create_node(bot=self.bot,
|
||||
host=self.bot.config["wavelink"]["host"],
|
||||
port=self.bot.config["wavelink"]["port"],
|
||||
password=self.bot.config["wavelink"]["password"],)
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_wavelink_track_end(self, player, track, reason):
|
||||
print("track ended")
|
||||
if not self.queue.is_empty and reason == 'FINISHED':
|
||||
await player.play(self.queue.get())
|
||||
|
||||
@bridge.bridge_command(alises=["j"])
|
||||
async def join(self, ctx, *, args: str=""):
|
||||
await ctx.defer()
|
||||
if ctx.author.voice is None and args == "":
|
||||
await ctx.respond("You are not in a voice channel")
|
||||
elif args != "":
|
||||
channel = self.bot.get_channel(discord.utils.get(ctx.guild.channels, name=args).id)
|
||||
await channel.connect(cls=wavelink.Player)
|
||||
else:
|
||||
await ctx.author.voice.channel.connect(cls=wavelink.Player)
|
||||
|
||||
@bridge.bridge_command(alises=["l"])
|
||||
async def leave(self, ctx):
|
||||
await ctx.defer()
|
||||
if ctx.voice_client is None:
|
||||
await ctx.respond("I am not in a voice channel")
|
||||
else:
|
||||
await ctx.voice_client.disconnect()
|
||||
|
||||
@bridge.bridge_command(aliases=["p"])
|
||||
async def play(self, ctx, *, link: str=""):
|
||||
await ctx.defer()
|
||||
providedchannel = False
|
||||
queueoverride = False
|
||||
earape = False
|
||||
channel = ""
|
||||
args = link.split(" -")
|
||||
if len(args) > 1:
|
||||
for arg in range(len(args)):
|
||||
if args[arg].startswith("channel") or args[arg].startswith("c"):
|
||||
channel = self.bot.get_channel(discord.utils.get(ctx.guild.channels, name=args[arg].split(" ")[1]).id)
|
||||
providedchannel = True
|
||||
if args[arg].startswith("now") or args[arg].startswith("n"):
|
||||
queueoverride = True
|
||||
if args[arg].startswith("earrape") or args[arg].startswith("e"):
|
||||
earape = True
|
||||
track = await wavelink.YouTubeTrack.search(args[0], return_first=True)
|
||||
|
||||
|
||||
if providedchannel and ctx.author.guild_permissions.administrator == False:
|
||||
await ctx.respond("You do not have permission to specify a channel")
|
||||
return
|
||||
if queueoverride and ctx.author.guild_permissions.administrator == False:
|
||||
await ctx.respond("You do not have permission to override the queue")
|
||||
return
|
||||
if earape and ctx.author.guild_permissions.administrator == False:
|
||||
await ctx.respond("You do not have permission to earrape")
|
||||
return
|
||||
|
||||
|
||||
if ctx.author.voice is None and channel == "":
|
||||
await ctx.respond("You are not in a voice channel, to specify a channel use `play <link> -channel <channel>`")
|
||||
return
|
||||
|
||||
if ctx.voice_client is None:
|
||||
if channel == "":
|
||||
channel = ctx.author.voice.channel
|
||||
await channel.connect(cls=wavelink.Player)
|
||||
|
||||
if link == "" and ctx.voice_client.is_paused():
|
||||
await ctx.voice_client.resume()
|
||||
return
|
||||
|
||||
if ctx.voice_client.is_paused():
|
||||
ctx.voice_client.resume()
|
||||
|
||||
if (self.queue.is_empty and not ctx.voice_client.is_playing()) or queueoverride:
|
||||
#not implemented
|
||||
#if earape:
|
||||
#print("earrape")
|
||||
#await ctx.voice_client.set_filter(wavelink.Filter(distortion=wavelink.Distortion(sin_offset=2,sin_scale=2,tan_offset=3)),seek=True)
|
||||
|
||||
await ctx.voice_client.play(track)
|
||||
await ctx.respond(f"Now playing: {track.title} by {track.author}\n {track.uri}")
|
||||
else:
|
||||
self.queue.put(item=track)
|
||||
await ctx.respond(f"Added to queue: {track.title} by {track.author}\n {track.uri}")
|
||||
|
||||
@bridge.bridge_command(aliases=["stop","s"])
|
||||
async def pause(self, ctx):
|
||||
await ctx.defer()
|
||||
if ctx.voice_client is None:
|
||||
await ctx.respond("I am not in a voice channel")
|
||||
else:
|
||||
await ctx.voice_client.pause()
|
||||
await ctx.respond("Paused")
|
||||
|
||||
@bridge.bridge_command(aliases=["next","n","sk"])
|
||||
async def skip(self, ctx):
|
||||
await ctx.defer()
|
||||
if ctx.voice_client is None:
|
||||
await ctx.respond("I am not in a voice channel")
|
||||
else:
|
||||
await ctx.voice_client.play(self.queue.get())
|
||||
await ctx.respond("Skipped")
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Voice(bot))
|
||||
@ -1 +0,0 @@
|
||||
1.2.5
|
||||
@ -1,5 +0,0 @@
|
||||
[loggers]
|
||||
keys=root,bot,storage,update,version,discord,pymongo,os
|
||||
|
||||
[handlers]
|
||||
keys=consoleHandler,fileHandler
|
||||
@ -1,4 +0,0 @@
|
||||
py-cord[voice]
|
||||
pymongo
|
||||
wavelink
|
||||
pynacl
|
||||
@ -1,6 +1,6 @@
|
||||
FROM python:3.12-slim
|
||||
RUN mkdir -p /app
|
||||
COPY . /app
|
||||
COPY py/. /app
|
||||
WORKDIR /app
|
||||
RUN pip install -r requirements.txt
|
||||
ENTRYPOINT ["python", "-u", "bot.py"]
|
||||
@ -18,6 +18,7 @@ bot = bridge.Bot(
|
||||
|
||||
bot.load_extension("cogs.reply")
|
||||
bot.load_extension("cogs.counting")
|
||||
bot.load_extension("cogs.settings")
|
||||
|
||||
uri = f"mongodb://{env['DB_USERNAME']}:{env['DB_PASSWORD']}@{env['DB_HOST']}/?authSource=admin"
|
||||
bot.db = MongoClient(uri)["turdbot"]
|
||||
|
||||
0
py/cogs/future.py
Normal file
0
py/cogs/future.py
Normal file
@ -5,8 +5,8 @@ class Reply(commands.Cog):
|
||||
self.bot = bot
|
||||
|
||||
@bridge.bridge_command()
|
||||
async def reply(self, ctx, *args):
|
||||
await ctx.send(args[0:])
|
||||
async def reply(self, ctx, args):
|
||||
await ctx.respond(args)
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Reply(bot))
|
||||
16
py/cogs/settings.py
Normal file
16
py/cogs/settings.py
Normal file
@ -0,0 +1,16 @@
|
||||
from discord.ext import bridge, commands
|
||||
from bin.storage import storage
|
||||
|
||||
class Settings(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@bridge.bridge_group(aliases=["set", "s"], invoke_without_command=True)
|
||||
async def settings(self, ctx):
|
||||
await ctx.respond("invalid command, see !help settings for more info")
|
||||
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Settings(bot))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user