Compare commits
9
Commits
ssh
..
oldversion
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9c6e6ce80 | ||
|
|
89c618e7bc | ||
|
|
09882ef75d | ||
|
|
c354ca6362 | ||
|
|
0306f11305 | ||
|
|
3668ea7d98 | ||
|
|
534050a991 | ||
|
|
2893f516dc | ||
|
|
be20e90f08 |
@@ -1 +1,7 @@
|
||||
liberapay: marcpartensky
|
||||
patreon: marcpartensky
|
||||
github: marcpartensky
|
||||
custom:
|
||||
# - monero:43J2XmRtjDPRLD35UsYGH2AZamFBQz7dt4VdvZXVm3SuadTrvcoXUXBRUNHqukFte23Q5TWXqhbwaLJJgoVQzzbe2AJDANQ
|
||||
- https://paypal.me/marcpartensky
|
||||
- https://buymeacoffee.com/marcpartensky
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -7,7 +7,7 @@ dev:
|
||||
docker-compose -f docker-compose.yml up -d --build --force-recreate --remove-orphans dev
|
||||
prod:
|
||||
docker-compose -f docker-compose.yml up -d --build --force-recreate --remove-orphans prod
|
||||
build: update
|
||||
build:
|
||||
docker-compose -f docker-compose.yml build prod
|
||||
push: build
|
||||
docker-compose -f docker-compose.yml push prod
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ unidecode = '*'
|
||||
future = '*'
|
||||
selenium = "*"
|
||||
fake-useragent = "*"
|
||||
colorama = "*"
|
||||
|
||||
[dev-packages]
|
||||
black = "*"
|
||||
|
||||
Generated
+44
-38
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "69045c5ed50ceb66ccd16448ca3f90350295e80a09b9f9a343644059692c9093"
|
||||
"sha256": "6909a0620012e7fdf83163dbcde4834a1157c99d5bf649706532bc32fea71a83"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
@@ -16,14 +16,6 @@
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"aenum": {
|
||||
"hashes": [
|
||||
"sha256:260225470b49429f5893a195a8b99c73a8d182be42bf90c37c93e7b20e44eaae",
|
||||
"sha256:aaebe735508d9cbc72cd6adfb59660a5e676dfbeb6fb24fb090041e7ddb8d3b3",
|
||||
"sha256:f9d20f7302ce3dc3639b3f75c3b3e146f3b22409a6b4513c1f0bd6dbdfcbd8c1"
|
||||
],
|
||||
"version": "==2.2.6"
|
||||
},
|
||||
"aiohttp": {
|
||||
"hashes": [
|
||||
"sha256:02f46fc0e3c5ac58b80d4d56eb0a7c7d97fcef69ace9326289fb9f1955e65cfe",
|
||||
@@ -186,6 +178,14 @@
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
||||
"version": "==7.1.2"
|
||||
},
|
||||
"colorama": {
|
||||
"hashes": [
|
||||
"sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b",
|
||||
"sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.4.4"
|
||||
},
|
||||
"commonmark": {
|
||||
"hashes": [
|
||||
"sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60",
|
||||
@@ -265,11 +265,11 @@
|
||||
},
|
||||
"fbchat": {
|
||||
"hashes": [
|
||||
"sha256:0738ffd14b0c944174e2e995fc698f80868824be6eff62d527555ddfb7e3fd30",
|
||||
"sha256:a5c81f21823cd185deb607d67aef40c35449f1407de56df66d10186285184307"
|
||||
"sha256:a901063ab96392ebbb6dc623f50ffdb1aed2885b2875313d730b84e593fb88e0",
|
||||
"sha256:fda62a5b27752aab42dd004f7ebbc04dfa9c75939bae2aba3debae70fa47fcbc"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.9.7"
|
||||
"version": "==2.0.0a5"
|
||||
},
|
||||
"future": {
|
||||
"hashes": [
|
||||
@@ -469,7 +469,7 @@
|
||||
"sha256:feba80698173761cddd814fa22e88b0661e98cb810f9f986c54aa34d281e4937",
|
||||
"sha256:feea820722e69451743a3d56ad74948b68bf456984d63c1a92e8347b7b88452d"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"markers": "python_full_version >= '3.7.0'",
|
||||
"version": "==6.0.2"
|
||||
},
|
||||
"nightcore": {
|
||||
@@ -745,6 +745,7 @@
|
||||
"sha256:ea6841bc3a76fa4942ce00f3bda7d436fda21e2d91602b9e21b7ca9ecab8f3ff",
|
||||
"sha256:f8851ab9041756003119368c1e6cd0b9c631f46d686b3904b18c0139f4419f80"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==1.4.0"
|
||||
},
|
||||
"pyopenssl": {
|
||||
@@ -776,7 +777,7 @@
|
||||
"sha256:45c6065746b500cf2ea3d6fb474a3c6298fb2ceca9ca25e5d6dea7fefd0cfa96",
|
||||
"sha256:dbe50d4c9a7715bcb426f1fb8ddcc9602fa4698d0e7667360dc56b2248ee6d8d"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"markers": "python_full_version >= '3.7.0'",
|
||||
"version": "==3.2.3"
|
||||
},
|
||||
"pyyaml": {
|
||||
@@ -967,7 +968,7 @@
|
||||
"sha256:670a52d3115d0e879e1ac838a4eb999af32f858163e3a704fe4839de2a676070",
|
||||
"sha256:fb2d48e4eab0dfb786a472cd514aaadc71e3445b203bc300bad93daa75d77c1a"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"markers": "python_full_version >= '3.7.0'",
|
||||
"version": "==0.20.0"
|
||||
},
|
||||
"trio-websocket": {
|
||||
@@ -995,10 +996,7 @@
|
||||
"version": "==1.3.4"
|
||||
},
|
||||
"urllib3": {
|
||||
"extras": [
|
||||
"secure",
|
||||
"socks"
|
||||
],
|
||||
"extras": [],
|
||||
"hashes": [
|
||||
"sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14",
|
||||
"sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e"
|
||||
@@ -1096,7 +1094,7 @@
|
||||
"sha256:2218cb57952d90b9fca325c0dcfb08c3bda93e8fd8070b0a17f048e2e47a521b",
|
||||
"sha256:a2e56bfd5c7cd83c1369d83b5feccd6d37798b74872866e62616e0ecf111bda8"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"markers": "python_full_version >= '3.7.0'",
|
||||
"version": "==1.1.0"
|
||||
},
|
||||
"xmltodict": {
|
||||
@@ -1197,11 +1195,11 @@
|
||||
"develop": {
|
||||
"astroid": {
|
||||
"hashes": [
|
||||
"sha256:14ffbb4f6aa2cf474a0834014005487f7ecd8924996083ab411e7fa0b508ce0b",
|
||||
"sha256:f4e4ec5294c4b07ac38bab9ca5ddd3914d4bf46f9006eb5c0ae755755061044e"
|
||||
"sha256:3975a0bd5373bdce166e60c851cfcbaf21ee96de80ec518c1f4cb3e94c3fb334",
|
||||
"sha256:ab7f36e8a78b8e54a62028ba6beef7561db4cdb6f2a5009ecc44a6f42b5697ef"
|
||||
],
|
||||
"markers": "python_full_version >= '3.6.2'",
|
||||
"version": "==2.11.5"
|
||||
"markers": "python_version ~= '3.6'",
|
||||
"version": "==2.6.6"
|
||||
},
|
||||
"black": {
|
||||
"hashes": [
|
||||
@@ -1240,14 +1238,6 @@
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
||||
"version": "==7.1.2"
|
||||
},
|
||||
"dill": {
|
||||
"hashes": [
|
||||
"sha256:33501d03270bbe410c72639b350e941882a8b0fd55357580fbc873fba0c59302",
|
||||
"sha256:d75e41f3eff1eee599d738e76ba8f4ad98ea229db8b085318aa2b3333a208c86"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'",
|
||||
"version": "==0.3.5.1"
|
||||
},
|
||||
"isort": {
|
||||
"hashes": [
|
||||
"sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7",
|
||||
@@ -1309,11 +1299,11 @@
|
||||
},
|
||||
"mccabe": {
|
||||
"hashes": [
|
||||
"sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325",
|
||||
"sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"
|
||||
"sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
|
||||
"sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
|
||||
],
|
||||
"markers": "python_version >= '3.6'",
|
||||
"version": "==0.7.0"
|
||||
"version": "==0.6.1"
|
||||
},
|
||||
"mypy-extensions": {
|
||||
"hashes": [
|
||||
@@ -1347,11 +1337,27 @@
|
||||
},
|
||||
"pylint": {
|
||||
"hashes": [
|
||||
"sha256:095567c96e19e6f57b5b907e67d265ff535e588fe26b12b5ebe1fc5645b2c731",
|
||||
"sha256:705c620d388035bdd9ff8b44c5bcdd235bfb49d276d488dd2c8ff1736aa42526"
|
||||
"sha256:349b149e88e4357ed4f77ac3a4e61c0ab965cda293b6f4e58caf73d4b24ae551",
|
||||
"sha256:adc11bec00c2084bf55c81dd69e26f2793fef757547997d44b21aed038f74403"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.13.9"
|
||||
"version": "==3.0.0a4"
|
||||
},
|
||||
"setuptools": {
|
||||
"hashes": [
|
||||
"sha256:68e45d17c9281ba25dc0104eadd2647172b3472d9e01f911efa57965e8d51a36",
|
||||
"sha256:a43bdedf853c670e5fed28e5623403bad2f73cf02f9a2774e91def6bda8265a7"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==62.3.2"
|
||||
},
|
||||
"toml": {
|
||||
"hashes": [
|
||||
"sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b",
|
||||
"sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
|
||||
],
|
||||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==0.10.2"
|
||||
},
|
||||
"tomli": {
|
||||
"hashes": [
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import requests
|
||||
import discord
|
||||
|
||||
from discord.ext import commands, tasks
|
||||
from config.config import ialab_bot_url, cluster
|
||||
from config.config import cluster
|
||||
from rich import print
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class IALab(commands.Cog):
|
||||
def __init__(self, bot: commands.Bot, **kwargs):
|
||||
"""Initialize the ialab cog."""
|
||||
super().__init__(**kwargs)
|
||||
self.url = ialab_bot_url
|
||||
self.url = os.environ["IALAB_URL"]
|
||||
self.bot = bot
|
||||
|
||||
@commands.command()
|
||||
|
||||
@@ -7,7 +7,6 @@ import requests
|
||||
import discord
|
||||
|
||||
from discord.ext import commands, tasks
|
||||
from config.config import ialab_bot_url, cluster
|
||||
from rich import print
|
||||
|
||||
|
||||
|
||||
-81
@@ -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))
|
||||
@@ -15,7 +15,6 @@ link = "https://discordapp.com/oauth2/authorize?&client_id=703347349623144549&sc
|
||||
prefix = os.environ.get("DISCORD_PREFIX") or "."
|
||||
masters = [478552571510915072] # , 219949869220102147]
|
||||
wolfram = wolframalpha.Client(wolfram_alpha_id)
|
||||
ialab_bot_url = "https://ialab.marcpartensky.com"
|
||||
|
||||
roles = ["@Maître", "@Admin"]
|
||||
|
||||
|
||||
+6
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user