Compare commits

..
6 Commits
Author SHA1 Message Date
marc 1748c5f0b3 voicechannel 2022-12-20 17:02:55 +01:00
marc 0306f11305 funding 2022-12-20 17:02:27 +01:00
marc 3668ea7d98 fix 2022-06-01 21:10:06 +02:00
marc 534050a991 update 2022-05-23 01:25:32 +02:00
marc 2893f516dc latest 2022-05-22 00:04:41 +02:00
marc be20e90f08 colorama 2022-05-22 00:03:50 +02:00
8 changed files with 25 additions and 1529 deletions
+6
View File
@@ -1 +1,7 @@
liberapay: marcpartensky
patreon: marcpartensky
github: marcpartensky
custom:
# - monero:43J2XmRtjDPRLD35UsYGH2AZamFBQz7dt4VdvZXVm3SuadTrvcoXUXBRUNHqukFte23Q5TWXqhbwaLJJgoVQzzbe2AJDANQ
- https://paypal.me/marcpartensky
- https://buymeacoffee.com/marcpartensky
+6
View File
@@ -38,6 +38,12 @@ jobs:
with:
push: true
tags: marcpartensky/discord-bot:v${{ github.run_number }}.${{ steps.tag.outputs.tag }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: marcpartensky/discord-bot:latest
test-python-versions:
runs-on: ${{ matrix.os }}
+4
View File
@@ -19,3 +19,7 @@ setup:
pipenv install
recreate:
docker-compose -f docker-compose.yml up --force-recreate dev
fixwithbrew:
brew install python@3.8
sudo ln -sf /home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.12_1/bin/python3.8 /usr/bin/python3.8
+2
View File
@@ -36,6 +36,8 @@ unidecode = '*'
future = '*'
selenium = "*"
fake-useragent = "*"
colorama = "*"
discord-ext-audiorec = "*"
[dev-packages]
black = "*"
Generated
-1443
View File
File diff suppressed because it is too large Load Diff
-81
View File
@@ -1,81 +0,0 @@
#!/usr/bin/env python
"""Control ssh sessions."""
import typing
import discord
from pexpect import pxssh
from discord.ext import commands
from discord.ext.commands.core import has_role
import pexpect
SSH_ROLE = "Ssh"
class Ssh(commands.Cog):
"""Control ssh sessions."""
def __init__(self, bot: commands.Bot):
"""Initialize the cog with the bot."""
self.bot = bot
self.color: discord.Color = discord.Color.purple()
self.thumbnail: str = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/GNOME_Terminal_icon_2019.svg/1200px-GNOME_Terminal_icon_2019.svg.png"
self.timeout = 3600
self.shells: typing.Dict[int, pexpect.pty_spawn.spawn] = {}
@has_role(SSH_ROLE)
@commands.command()
async def ssh(self, ctx: commands.Context, hostname: str, port: int=0):
"""Run a command in a ssh session"""
username=""
await create_role_if_missing(ctx, SSH_ROLE, self.color)
embed = discord.Embed(color=self.color)
embed.set_thumbnail(url=self.thumbnail)
embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar)
embed.description = self.shell_path
shell = pxssh.pxssh()
shell.login(hostname, username, password)
self.shells[ctx.author.id] = shell
shell.sendline("echo $HOSTNAME")
hostname = shell.before.decode("utf-8")
embed.title = f"Connected to {hostname}"
await ctx.send(embed=embed)
@commands.command(name="shells")
async def list_shells(self, ctx: commands.Context):
"""List ."""
if len(self.shells) == 0:
return await ctx.send("> No active ssh connexion.")
embed = discord.Embed(title="Active ssh connexions:", color=self.color)
embed.set_thumbnail(url=self.thumbnail)
shell_users = []
for shell_user in map(self.bot.fetch_user, self.shells.keys()):
shell_users.append(f"- {await shell_user}")
embed.description = "\n".join(shell_users)
await ctx.send(embed=embed)
@commands.Cog.listener(name="on_message")
async def on_message(self, msg: discord.Message):
"""Read all messages"""
if msg.author == self.bot.user:
return
if msg.content.startswith(self.bot.command_prefix):
return
if msg.author.id in self.shells:
shell = self.shells[msg.author.id]
shell.sendline(msg.content)
shell.prompt()
output = shell.before.decode("utf-8")
print(output)
await msg.channel.send(output)
# async def cog_common_error(self, ctx, error):
# """Close all shell sessions."""
# for shell in self.shells.values():
# shell.close()
def setup(bot):
"""Setup the Shell cog."""
bot.add_cog(Ssh(bot))
+1
View File
@@ -6,6 +6,7 @@ from typing import List
import discord
from discord.ext import commands
from discord.ext.audiorec import NativeVoiceClient
from config.config import masters
+6 -5
View File
@@ -17,6 +17,7 @@ cffi==1.15.0
chardet==4.0.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
charset-normalizer==2.0.12; python_version >= '3'
click==7.1.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
colorama==0.4.4
commonmark==0.9.1
cryptography==37.0.2
deprecated==1.2.13; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
@@ -35,7 +36,7 @@ joblib==1.1.0; python_version >= '3.6'
libretranslatepy==2.1.1
lxml==4.8.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
more-itertools==8.13.0; python_version >= '3.5'
multidict==6.0.2; python_version >= '3.7'
multidict==6.0.2; python_full_version >= '3.7.0'
nightcore==1.1.0
numpy==1.22.4; python_version >= '3.8'
outcome==1.1.0; python_version >= '3.6'
@@ -55,7 +56,7 @@ pynacl==1.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2,
pyopenssl==22.0.0
pysocks==1.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
python-dotenv==0.20.0
python-utils==3.2.3; python_version >= '3.7'
python-utils==3.2.3; python_full_version >= '3.7.0'
pyyaml==6.0
requests-futures==1.0.0
requests==2.27.1
@@ -72,14 +73,14 @@ threadpoolctl==3.1.0; python_version >= '3.6'
torrequest==0.1.0
translate==3.6.1
trio-websocket==0.9.2; python_version >= '3.5'
trio==0.20.0; python_version >= '3.7'
trio==0.20.0; python_full_version >= '3.7.0'
typing-extensions==4.2.0; python_version < '3.9'
unidecode==1.3.4
urllib3[secure,socks]==1.26.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
urllib3[secure,socks]==1.26.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4.0'
wikipedia==1.4.0
wolframalpha==5.0.0
wrapt==1.14.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
wsproto==1.1.0; python_version >= '3.7'
wsproto==1.1.0; python_full_version >= '3.7.0'
xmltodict==0.13.0; python_version >= '3.4'
yarl==1.7.2; python_version >= '3.6'
youtube-dl==2021.12.17