General development process
- new cog commands - new voice cog - new requirements.txt - adjusted readme - added Dockerfile for faster deployment (still WIP) - other general things
This commit is contained in:
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
README.md
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
config/config.py
|
config/config.py
|
||||||
.vscode/
|
.vscode/
|
||||||
|
*.log
|
||||||
|
|||||||
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
FROM python:3.6
|
||||||
|
|
||||||
|
MAINTAINER Marco Thomas
|
||||||
|
|
||||||
|
RUN mkdir /aquabot-docker
|
||||||
|
WORKDIR /aquabot-docker
|
||||||
|
COPY . /aquabot-docker
|
||||||
|
|
||||||
|
RUN pip install --user -r requirements.txt
|
||||||
|
|
||||||
|
CMD ["python", "aquabot.py"]
|
||||||
34
README.md
34
README.md
@@ -11,15 +11,34 @@ here and there.
|
|||||||
Also note that this bot is still in its very early stages, so there is no
|
Also note that this bot is still in its very early stages, so there is no
|
||||||
guaranty that all features work!
|
guaranty that all features work!
|
||||||
|
|
||||||
Support and Report requests are handled via Discord (Link above).
|
Support and report requests are handled via Discord (Link above).
|
||||||
|
|
||||||
Installation
|
Installation - Docker
|
||||||
------------
|
---------------------
|
||||||
|
|
||||||
Use `pip install discord.py[voice]` to install the latest version of discord.py.
|
`WIP!`
|
||||||
|
|
||||||
Then, after cloning this repository with
|
+ Clone this repository with `git clne https://github.com/CramMK/aquabot`
|
||||||
`git clone https://github.com/crammk/aquabot`, you can run the `aquabot.py`.
|
|
||||||
|
+ Create a `config/config.py`, using the `config/config_example.py` as a
|
||||||
|
guideline
|
||||||
|
|
||||||
|
+ Launch the Container
|
||||||
|
|
||||||
|
Installation - pip
|
||||||
|
------------------
|
||||||
|
|
||||||
|
+ Clone this repository with `git clone https://github.com/CramMK/aquabot`
|
||||||
|
|
||||||
|
+ **OPTIONAL:** A virtual environment can be created at this point
|
||||||
|
|
||||||
|
+ Use `pip install --user -r requirements.txt` to install all dependencies
|
||||||
|
needed for the bot
|
||||||
|
|
||||||
|
+ Create a `config/config.py`, using the `config/config_example.py` as a
|
||||||
|
guideline
|
||||||
|
|
||||||
|
+ Finally, run `python aquabot`
|
||||||
|
|
||||||
Commands
|
Commands
|
||||||
------
|
------
|
||||||
@@ -41,5 +60,4 @@ To use the bot you need to add a `config/config.py` file. For reference, see
|
|||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
python>=3.6.0
|
+ python>=3.6.0
|
||||||
discord.py>=1.0.0a
|
|
||||||
|
|||||||
64
aquabot.py
64
aquabot.py
@@ -8,33 +8,69 @@ https://discordpy.readthedocs.io/en/latest/intro.html
|
|||||||
# IMPORTS - external
|
# IMPORTS - external
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
import logging
|
||||||
|
|
||||||
# IMPORTS - internal
|
# IMPORTS - internal
|
||||||
import loadconfig
|
import loadconfig
|
||||||
|
|
||||||
# CONSTANTS
|
# LOGGING
|
||||||
|
logger = logging.getLogger("discord")
|
||||||
|
# https://docs.python.org/3/library/logging.html#levels
|
||||||
|
logger.setlevel(logging.INFO)
|
||||||
|
handler = logging.FileHandler(
|
||||||
|
filename="discord_%(asctime)s.log",
|
||||||
|
encoding="utf-8",
|
||||||
|
mode="w"
|
||||||
|
)
|
||||||
|
handler.setFormatter(
|
||||||
|
logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")
|
||||||
|
)
|
||||||
|
logger.addHandler(handler)
|
||||||
|
|
||||||
|
# SOME DATA THAT CAN BE USED LATER
|
||||||
|
metadata = {
|
||||||
|
"name": f"{bot.user.name} - {bot.user.id}",
|
||||||
|
"admin": f"{self.bot.AppInfo.owner}",
|
||||||
|
"prefix": f"{loadconfig.__token__}",
|
||||||
|
"discordpy_version": f"{discord.__version__}",
|
||||||
|
"python_version": f"{platform.python_version}",
|
||||||
|
"os": f"{platform.system()} {platform.release()} {platform.version()}"
|
||||||
|
}
|
||||||
|
|
||||||
# INIT
|
# INIT THE BOT
|
||||||
bot = commands.Bot(
|
bot = commands.Bot(
|
||||||
command_prefix=loadconfig.__prefix__,
|
command_prefix=loadconfig.__prefix__,
|
||||||
description="Holy Goddess Aqua!"
|
description="Holy Goddess Aqua!"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# LOAD COGS SPECIFIED IN 'config/cogs.py'
|
||||||
for cog in loadconfig.__cogs__:
|
for cog in loadconfig.__cogs__:
|
||||||
try:
|
try:
|
||||||
bot.load_extension(cog)
|
bot.load_extension(cog)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
print(f"Error while trying to load cog {cog}")
|
print(f"ERROR: {type(e).__name__} - {e}")
|
||||||
|
else:
|
||||||
|
print(f"SUCCESS: Loaded {cog}")
|
||||||
|
|
||||||
# BOT
|
# BOT STARTING EVENT
|
||||||
# https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f"""
|
"""
|
||||||
Logged in as: {bot.user.name} - {bot.user.id}\n
|
This prints some information about the bot, while starting up
|
||||||
Version: {discord.__version__}\n
|
|
||||||
""")
|
Inspired by:
|
||||||
|
https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be
|
||||||
|
"""
|
||||||
|
|
||||||
|
startup = f"""
|
||||||
|
Bot Name: {metadata["name"]}\n
|
||||||
|
Admin: {metadata["admin"]}\n
|
||||||
|
Command Prefix: {metadata["prefix"]}\n
|
||||||
|
discord.py Version: {metadata["discordpy_version"]}\n
|
||||||
|
python Version: {metadata["python_version"]}\n
|
||||||
|
OS: {metadata["os"]}\n
|
||||||
|
"""
|
||||||
|
print(startup)
|
||||||
|
|
||||||
status = f"Hentai | {loadconfig.__prefix__}aquabot"
|
status = f"Hentai | {loadconfig.__prefix__}aquabot"
|
||||||
activity = discord.Activity(name=status, type=discord.ActivityType.watching)
|
activity = discord.Activity(name=status, type=discord.ActivityType.watching)
|
||||||
@@ -42,5 +78,9 @@ async def on_ready():
|
|||||||
|
|
||||||
print(f"AquaBot is ready!\n")
|
print(f"AquaBot is ready!\n")
|
||||||
|
|
||||||
|
# START BOT
|
||||||
bot.run(loadconfig.__token__, bot=True, reconnect=True)
|
bot.run(
|
||||||
|
loadconfig.__token__,
|
||||||
|
bot=True,
|
||||||
|
reconnect=True
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
#
|
|
||||||
# A Cog that add admin command, usable within the Discord Client
|
|
||||||
#
|
|
||||||
# https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
|
||||||
#
|
|
||||||
# "load", "unload", "reload"
|
|
||||||
# https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be
|
|
||||||
#
|
|
||||||
"""
|
"""
|
||||||
Admin commands, that can be used from within the chat
|
Admin commands, that can be used from within the chat:
|
||||||
|
- load
|
||||||
|
- unload
|
||||||
|
- reload
|
||||||
|
|
||||||
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
||||||
|
|
||||||
"load", "unload", "reload"
|
|
||||||
https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be
|
https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
Some anime-related commands
|
Some anime-related commands:
|
||||||
|
|
||||||
|
|
||||||
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
||||||
"""
|
"""
|
||||||
@@ -9,7 +10,7 @@ import discord
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
# COG INIT
|
# COG INIT
|
||||||
class Adnime(commands.Cog):
|
class Anime(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@@ -17,4 +18,4 @@ class Adnime(commands.Cog):
|
|||||||
|
|
||||||
# COG ENDING
|
# COG ENDING
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Adnime(bot))
|
bot.add_cog(Anime(bot))
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
Some general commands
|
Some general commands:
|
||||||
|
- about
|
||||||
|
|
||||||
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
||||||
"""
|
"""
|
||||||
@@ -8,6 +9,9 @@ https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
|
# IMPORTS - internal
|
||||||
|
from aquabot import metadata
|
||||||
|
|
||||||
# COG INIT
|
# COG INIT
|
||||||
class General(commands.Cog):
|
class General(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
@@ -21,10 +25,18 @@ class General(commands.Cog):
|
|||||||
"""
|
"""
|
||||||
embed = discord.Embed(colour=discord.Colour.blue())
|
embed = discord.Embed(colour=discord.Colour.blue())
|
||||||
|
|
||||||
embed.add_field(name="test", value="test2")
|
embed.add_field(name="Bot Name", value=metadata["name"], inline=True)
|
||||||
|
embed.add_field(name="Admin", value=metadata["admin"], inline=True)
|
||||||
embed.set_footer(text="footer", icon_url="img/avatar.png")
|
embed.add_field(name="Prefix", value=metadata["prefix"], inline=True)
|
||||||
|
embed.add_field(name="discord.py Version", value=metadata["discordpy_version"], inline=True)
|
||||||
|
embed.add_field(name="python Version", value=metadata["python_version"], inline=True)
|
||||||
|
embed.add_field(name="OS", value=metadata["os"], inline=True)
|
||||||
|
|
||||||
|
footer_text = """
|
||||||
|
This Bot is an OpenSource project by Marc and can be found on
|
||||||
|
github.com/CramMK/aquabot
|
||||||
|
"""
|
||||||
|
embed.set_footer(text=footer_text, icon_url="img/avatar.png")
|
||||||
|
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
Some help for the users
|
Some help for the users:
|
||||||
|
- aquabot
|
||||||
|
|
||||||
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
||||||
"""
|
"""
|
||||||
@@ -14,16 +15,15 @@ class Help(commands.Cog):
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
# COG BODY
|
# COG BODY
|
||||||
@commands.command( name="aquabot")
|
@commands.command(name="aquabot")
|
||||||
async def aquabot(self, ctx):
|
async def aquabot(self, ctx):
|
||||||
"""
|
"""
|
||||||
Sends a short help for new users
|
Sends a short help for new users
|
||||||
"""
|
"""
|
||||||
response = """
|
response = """
|
||||||
I'm the usele... divine AquaBot!
|
I'm the usele... divine AquaBot!\n
|
||||||
If you need help, try using the `help` command!
|
If you need help, try using the `help` command!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
await ctx.send(response)
|
await ctx.send(response)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Some nice utility
|
Some (more or less) handy utility:
|
||||||
|
- invitelink
|
||||||
|
- pat
|
||||||
|
|
||||||
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
||||||
"""
|
"""
|
||||||
@@ -19,7 +21,6 @@ class Utility(commands.Cog):
|
|||||||
"""
|
"""
|
||||||
Sends the server's invitelink to chat
|
Sends the server's invitelink to chat
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO fetch this from config so more servers are supported
|
# TODO fetch this from config so more servers are supported
|
||||||
link = "Here is our invite link: https://discordapp.com/invite/HbYfyJT"
|
link = "Here is our invite link: https://discordapp.com/invite/HbYfyJT"
|
||||||
await ctx.send(link)
|
await ctx.send(link)
|
||||||
|
|||||||
76
cogs/voice.py
Normal file
76
cogs/voice.py
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
"""
|
||||||
|
Make Aqua be able to join voice channel and play audio:
|
||||||
|
- join
|
||||||
|
- leave
|
||||||
|
- play
|
||||||
|
|
||||||
|
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
||||||
|
"""
|
||||||
|
|
||||||
|
# IMPORTS
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from discord.utils import get
|
||||||
|
|
||||||
|
# COG INIT
|
||||||
|
class Voice(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
# COG BODY
|
||||||
|
@commands.command(name="join", aliases=["j"])
|
||||||
|
@commands.guild_only()
|
||||||
|
async def join(self, ctx):
|
||||||
|
"""
|
||||||
|
Tries to join the author's current voice channel
|
||||||
|
"""
|
||||||
|
channel = ctx.message.author.voice.channel
|
||||||
|
if not channel:
|
||||||
|
ctx.send:("You're not connected to a voice channel!")
|
||||||
|
return
|
||||||
|
|
||||||
|
voice = get(bot.voice_clients, guild=ctx.guild)
|
||||||
|
|
||||||
|
if voice and voice.is_connected():
|
||||||
|
await voice.move_to(channel)
|
||||||
|
else:
|
||||||
|
voice = await channel.connect()
|
||||||
|
await ctx.send(f"`Joined {channel}!`")
|
||||||
|
""" useless?
|
||||||
|
await voice.disconnect()
|
||||||
|
|
||||||
|
if voice and voice.is_connected():
|
||||||
|
await voice.move_to(channel)
|
||||||
|
else:
|
||||||
|
voice = await channel.connect()
|
||||||
|
await ctx.send(f"`Joined {channel}!`")
|
||||||
|
"""
|
||||||
|
|
||||||
|
@commands.command(name="leave", aliases=["quit, l"])
|
||||||
|
@commands.guild_only()
|
||||||
|
async def leave(self, ctx):
|
||||||
|
"""
|
||||||
|
Leaves the voice channel, if connected
|
||||||
|
"""
|
||||||
|
channel = ctx.message.author.voice.channel
|
||||||
|
voice = get(bot.voice_clients, guild=ctx.guild)
|
||||||
|
|
||||||
|
if voice and voice.is_connected():
|
||||||
|
await voice.disconnect()
|
||||||
|
await ctx.send(f"`Left {channel}!`")
|
||||||
|
else:
|
||||||
|
ctx.send("I'm not connected to a channel!")
|
||||||
|
|
||||||
|
@commands.command(name="play", aliases=["p"])
|
||||||
|
@commands.guild_only()
|
||||||
|
async def play(self, ctx, url: str):
|
||||||
|
"""
|
||||||
|
Plays music from YT link specifies
|
||||||
|
"""
|
||||||
|
# TODO
|
||||||
|
ctx.send("This module is not working yet!")
|
||||||
|
|
||||||
|
|
||||||
|
# COG ENDING
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(Voice(bot))
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Welcoming new users etc.
|
Welcoming new users etc.:
|
||||||
|
- listener: join
|
||||||
|
- hello
|
||||||
|
|
||||||
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
|
||||||
"""
|
"""
|
||||||
@@ -28,9 +30,12 @@ class Welcome(commands.Cog):
|
|||||||
|
|
||||||
@commands.command(name="hello")
|
@commands.command(name="hello")
|
||||||
async def hello(self, ctx):
|
async def hello(self, ctx):
|
||||||
|
"""
|
||||||
|
Sends a simple reply to the user
|
||||||
|
"""
|
||||||
await ctx.send(f"Hello {ctx.author.mention}!")
|
await ctx.send(f"Hello {ctx.author.mention}!")
|
||||||
|
|
||||||
|
|
||||||
# COG ENDING
|
# COG ENDING
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Welcome(bot))
|
bot.add_cog(Welcome(bot))
|
||||||
@@ -6,4 +6,7 @@ loadconfig.py then gets called in aquabot.py
|
|||||||
|
|
||||||
from config.cogs import __cogs__
|
from config.cogs import __cogs__
|
||||||
|
|
||||||
from config.config import __token__, __prefix__
|
try:
|
||||||
|
from config.config import __token__, __prefix__
|
||||||
|
except ImportError as e:
|
||||||
|
print(f"Error while importing: {e}")
|
||||||
|
|||||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
discord.py[voice]=1.2.5
|
||||||
Reference in New Issue
Block a user