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

Compare commits

..

5 commits

Author SHA1 Message Date
b5b801f07f
timestamp: Add list[str] for timestamp styles
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2024-11-07 00:43:07 +03:00
befd494de2
random: Show the given range as a table
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2024-11-07 00:33:32 +03:00
4211f72b9d
timestamp: Add chat syntax table
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2024-11-06 23:36:24 +03:00
92797df873
timestamp: Send formatted timestamp
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2024-11-06 23:26:04 +03:00
4b7b7bc062
server: Fix stats by using ctx.author.server
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2024-11-06 23:12:29 +03:00
4 changed files with 22 additions and 102 deletions

View file

@ -1,93 +0,0 @@
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,4 +2,5 @@
.venv/
build/
dist/
__pycache__/
*.spec

View file

@ -36,18 +36,25 @@ class Client(commands.CommandsClient):
return
if x > y:
message = randrange(y, x + 1)
await ctx.send(f"**{str(message)}** `({y};{x})`")
result = randrange(y, x + 1)
await ctx.send(extensions.random_message(result, y, x))
return
message = randrange(x, y + 1)
await ctx.send(f"**{str(message)}** `({x};{y})`")
result = randrange(x, y + 1)
await ctx.send(extensions.random_message(result, x, y))
@commands.command()
async def timestamp(self, ctx: commands.Context):
"""Shows current timestamp"""
message = trunc(time())
await ctx.send(str(message))
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)
@commands.command()
async def self(self, ctx: commands.Context):
@ -99,7 +106,6 @@ 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"
@ -108,7 +114,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(state.users)} |\n"
f"| Channels | {len(state.channels)} |\n"
f"| Members | {len(server.members)} |\n"
f"| Channels | {len(server.channels)} |\n"
f"| Roles | {len(server.roles)} |\n"
f"| Emojis | {len(server.emojis)} |")

View file

@ -1,2 +1,8 @@
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}|")