1
0
Fork 0
mirror of https://git.mctaylors.ru/mctaylors/Lurker.git synced 2024-11-25 10:58:02 +03:00

Compare commits

..

1 commit

Author SHA1 Message Date
e1c0ee065a
Add automatic deployment
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2024-11-06 21:55:31 +03:00
4 changed files with 102 additions and 22 deletions

View file

@ -0,0 +1,93 @@
name: Update production
on:
push:
branches:
- master
jobs:
build-upload-artifact:
name: Build and upload Lurker as artifact
runs-on: docker
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Setup virtual environment
run: python -m venv .venv/
- name: Install necessary packages using pip
run: ./.venv/bin/pip install $PIP_PACKAGES
env:
PIP_PACKAGES: ${{vars.PIP_PACKAGES}}
- name: Build binary
run: ./.venv/bin/pyinstaller $PYINSTALLER_FLAGS main.py
env:
PYINSTALLER_FLAGS: ${{vars.PYINSTALLER_FLAGS}}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: lurker-bin
path: dist/
update-production:
name: Update Lurker on production
runs-on: docker
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: lurker-bin
- name: Copy SSH key
run: |
install -m 600 -D /dev/null ~/.ssh/id_ed25519
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
shell: bash
env:
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
- name: Generate SSH known hosts file
run: |
ssh-keyscan -H -p $SSH_PORT $SSH_HOST > ~/.ssh/known_hosts
shell: bash
env:
SSH_HOST: ${{secrets.SSH_HOST}}
SSH_PORT: ${{secrets.SSH_PORT}}
- name: Stop currently running instance
run: |
ssh $SSH_USER@$SSH_HOST $STOP_COMMAND
shell: bash
env:
SSH_USER: ${{secrets.SSH_USER}}
SSH_HOST: ${{secrets.SSH_HOST}}
STOP_COMMAND: ${{vars.STOP_COMMAND}}
- name: Upload artifact
run: |
scp -r $UPLOAD_FROM $SSH_USER@$SSH_HOST:$UPLOAD_TO
shell: bash
env:
SSH_USER: ${{secrets.SSH_USER}}
SSH_HOST: ${{secrets.SSH_HOST}}
UPLOAD_FROM: ${{vars.UPLOAD_FROM}}
UPLOAD_TO: ${{vars.UPLOAD_TO}}
- name: Start new instance
run: |
ssh $SSH_USER@$SSH_HOST $START_COMMAND
shell: bash
env:
SSH_USER: ${{secrets.SSH_USER}}
SSH_HOST: ${{secrets.SSH_HOST}}
START_COMMAND: ${{vars.START_COMMAND}}

1
.gitignore vendored
View file

@ -2,5 +2,4 @@
.venv/
build/
dist/
__pycache__/
*.spec

View file

@ -36,25 +36,18 @@ class Client(commands.CommandsClient):
return
if x > y:
result = randrange(y, x + 1)
await ctx.send(extensions.random_message(result, y, x))
message = randrange(y, x + 1)
await ctx.send(f"**{str(message)}** `({y};{x})`")
return
result = randrange(x, y + 1)
await ctx.send(extensions.random_message(result, x, y))
message = randrange(x, y + 1)
await ctx.send(f"**{str(message)}** `({x};{y})`")
@commands.command()
async def timestamp(self, ctx: commands.Context):
"""Shows current timestamp"""
timestamp = trunc(time())
table = str()
styles = ['d', 'D', 't', 'T', 'f', 'F', 'R']
for style in styles:
table = table + f"\n| `<t:{timestamp}:{style}>` | <t:{timestamp}:{style}> |"
await ctx.send(f"## {timestamp}\n"
f"| Chat syntax | Result |\n"
f"| --- | --- |"
+ table)
message = trunc(time())
await ctx.send(str(message))
@commands.command()
async def self(self, ctx: commands.Context):
@ -106,6 +99,7 @@ class Client(commands.CommandsClient):
if server.banner is not None:
banner = extensions.icon_info(server.banner)
state = server.state # used for statistics
await ctx.send(f"## {server.name}\n"
f"{description}\n"
f"| ID | `{server.id}` |\n| --- | --- |\n"
@ -114,7 +108,7 @@ class Client(commands.CommandsClient):
f"| Server banner | {banner} |\n"
f"| Server owner | {server.owner.original_name}#{server.owner.discriminator} |\n"
f"---\n| Statistics | Value |\n| --- | --- |\n"
f"| Members | {len(server.members)} |\n"
f"| Channels | {len(server.channels)} |\n"
f"| Members | {len(state.users)} |\n"
f"| Channels | {len(state.channels)} |\n"
f"| Roles | {len(server.roles)} |\n"
f"| Emojis | {len(server.emojis)} |")

View file

@ -1,8 +1,2 @@
def icon_info(icon):
return f"[{icon.filename}](<{icon.url}>) ({icon.width}x{icon.height})"
def random_message(result, min, max):
return (f"## {result}\n"
f"| Min | Max |\n"
f"| --- | --- |\n"
f"|{min}|{max}|")