refactor smal => mxsmal
This commit is contained in:
parent
3f6be78685
commit
7e984ef129
37 changed files with 142 additions and 72 deletions
8
.github/workflows/build.yaml
vendored
8
.github/workflows/build.yaml
vendored
|
|
@ -156,7 +156,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
SOURCE_DATE_EPOCH: ${{ needs.timestamp.outputs.sepoch }}
|
SOURCE_DATE_EPOCH: ${{ needs.timestamp.outputs.sepoch }}
|
||||||
run: |
|
run: |
|
||||||
cd smal/
|
cd mxsmal/
|
||||||
pip install build
|
pip install build
|
||||||
python -m build --sdist
|
python -m build --sdist
|
||||||
pip install ./dist/*.tar.gz
|
pip install ./dist/*.tar.gz
|
||||||
|
|
@ -165,7 +165,7 @@ jobs:
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: smal-${{ github.sha }}-sdist.zip
|
name: smal-${{ github.sha }}-sdist.zip
|
||||||
path: ./smal/dist/*.tar.gz
|
path: ./mxsmal/dist/*.tar.gz
|
||||||
|
|
||||||
|
|
||||||
smal-wheel:
|
smal-wheel:
|
||||||
|
|
@ -183,7 +183,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
SOURCE_DATE_EPOCH: ${{ needs.timestamp.outputs.sepoch }}
|
SOURCE_DATE_EPOCH: ${{ needs.timestamp.outputs.sepoch }}
|
||||||
run: |
|
run: |
|
||||||
cd smal/
|
cd mxsmal/
|
||||||
pip install build
|
pip install build
|
||||||
python -m build --wheel
|
python -m build --wheel
|
||||||
pip install ./dist/*.whl
|
pip install ./dist/*.whl
|
||||||
|
|
@ -192,7 +192,7 @@ jobs:
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: smal-${{ github.sha }}-wheel.zip
|
name: smal-${{ github.sha }}-wheel.zip
|
||||||
path: ./smal/dist/*.whl
|
path: ./mxsmal/dist/*.whl
|
||||||
|
|
||||||
|
|
||||||
smal-pypi:
|
smal-pypi:
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ EOF
|
||||||
RUN --mount=type=bind,from=pybuilder,source=/pygomx-wheel,target=/pygomx-wheel pip install /pygomx-wheel/*.whl
|
RUN --mount=type=bind,from=pybuilder,source=/pygomx-wheel,target=/pygomx-wheel pip install /pygomx-wheel/*.whl
|
||||||
|
|
||||||
FROM develop AS demobot
|
FROM develop AS demobot
|
||||||
WORKDIR /smal
|
WORKDIR /mxsmal
|
||||||
COPY smal /smal
|
COPY mxsmal /mxsmal
|
||||||
RUN pip install .
|
RUN pip install .
|
||||||
|
|
||||||
WORKDIR /demobot
|
WORKDIR /demobot
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,8 @@ the bot follows each invite (autojoin) and have two commands:
|
||||||
|
|
||||||
binary/package install:
|
binary/package install:
|
||||||
|
|
||||||
(only linux-amd64 for now)
|
pip install pygomx
|
||||||
pip install --index-url https://codeberg.org/api/packages/saces/pypi/simple/ --no-deps pygomx
|
pip install mxsmal
|
||||||
pip install git+https://codeberg.org/saces/pygomx.git#subdirectory=pygomx-deps
|
|
||||||
|
|
||||||
pip install git+https://codeberg.org/saces/pygomx.git#subdirectory=smal
|
|
||||||
|
|
||||||
|
|
||||||
install from source / develop (venv):
|
install from source / develop (venv):
|
||||||
|
|
@ -45,7 +42,7 @@ install from source / develop (venv):
|
||||||
cd pygomx
|
cd pygomx
|
||||||
pip install .
|
pip install .
|
||||||
|
|
||||||
cd ../smal
|
cd ../mxsmal
|
||||||
pip install [-e] .
|
pip install [-e] .
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ services:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Containerfile.debian
|
dockerfile: Containerfile.debian
|
||||||
target: develop
|
target: develop
|
||||||
working_dir: /smal
|
working_dir: /mxsmal
|
||||||
volumes:
|
volumes:
|
||||||
- ./smal:/smal:ro
|
- ./mxsmal:/mxsmal:ro
|
||||||
- ./work:/work
|
- ./work:/work
|
||||||
|
|
||||||
demobot:
|
demobot:
|
||||||
|
|
|
||||||
0
smal/.gitignore → mxsmal/.gitignore
vendored
0
smal/.gitignore → mxsmal/.gitignore
vendored
|
|
@ -4,7 +4,7 @@ Simple Matrix Application Library
|
||||||
|
|
||||||
sub libs:
|
sub libs:
|
||||||
- pymxutils: matrix cli utils
|
- pymxutils: matrix cli utils
|
||||||
- smal: the lib itself
|
- mxsmal: the lib itself
|
||||||
- smbl: simplematrixbotlib compat layer experiments (if any)
|
- smbl: simplematrixbotlib compat layer experiments (if any)
|
||||||
- demobot: simple demo bot
|
- demobot: simple demo bot
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ dependencies = [
|
||||||
|
|
||||||
[tool.setuptools.package-dir]
|
[tool.setuptools.package-dir]
|
||||||
"pymxutils" = "src/pymxutils"
|
"pymxutils" = "src/pymxutils"
|
||||||
"mxsmal" = "src/smal"
|
"mxsmal" = "src/mxsmal"
|
||||||
"smbl" = "src/smbl"
|
"smbl" = "src/smbl"
|
||||||
"demobot" = "src/demobot"
|
"demobot" = "src/demobot"
|
||||||
|
|
||||||
|
|
@ -40,6 +40,6 @@ mxlogout = "pymxutils.mxutils:logout"
|
||||||
mxclearaccount = "pymxutils.mxutils:clearaccount"
|
mxclearaccount = "pymxutils.mxutils:clearaccount"
|
||||||
mxserverinfo = "pymxutils.mxutils:serverinfo"
|
mxserverinfo = "pymxutils.mxutils:serverinfo"
|
||||||
mxpassitem = "pymxutils.mxutils:passitem"
|
mxpassitem = "pymxutils.mxutils:passitem"
|
||||||
smalsetup = "smal.smalsetup:smalsetup"
|
smalsetup = "mxsmal.smalsetup:smalsetup"
|
||||||
demobot = "demobot:main"
|
demobot = "demobot:main"
|
||||||
simplebot = "demobot.simple:main"
|
simplebot = "demobot.simple:main"
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2026 saces@c-base.org
|
# Copyright (C) 2026 saces@c-base.org
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
import logging
|
import logging
|
||||||
from smal.bot import SMALBot
|
from mxsmal.bot import SMALBot
|
||||||
|
|
||||||
# setup logging, we want timestamps
|
# setup logging, we want timestamps
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2026 saces@c-base.org
|
# Copyright (C) 2026 saces@c-base.org
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
import logging
|
import logging
|
||||||
from smal.simple.bot import SMALBot
|
from mxsmal.simple.bot import SMALBot
|
||||||
|
|
||||||
# setup logging, we want timestamps
|
# setup logging, we want timestamps
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
29
mxsmal/src/pymxutils/mxutils/accountinfo.py
Normal file
29
mxsmal/src/pymxutils/mxutils/accountinfo.py
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Copyright (C) 2026 saces@c-base.org
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
import click
|
||||||
|
import json
|
||||||
|
from _pygomx import lib, ffi
|
||||||
|
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.option("-u", "--url", "hs_url", metavar="url", help="homeserver url")
|
||||||
|
@click.option("-t", "--token", "token", metavar="token", help="access token")
|
||||||
|
def accountinfo(hs_url, token):
|
||||||
|
"""print info about this account devices"""
|
||||||
|
|
||||||
|
if hs_url is None and token is None:
|
||||||
|
r = lib.cliv0_mxpassitem(b".mxpass", b"*", b"*", b"*")
|
||||||
|
|
||||||
|
result = ffi.string(r).decode("utf-8")
|
||||||
|
lib.FreeCString(r)
|
||||||
|
|
||||||
|
result_dict = json.loads(result)
|
||||||
|
hs_url = result_dict["Matrixhost"]
|
||||||
|
token = result_dict["Token"]
|
||||||
|
|
||||||
|
r = lib.cliv0_accountinfo(
|
||||||
|
hs_url.encode(encoding="utf-8"), token.encode(encoding="utf-8")
|
||||||
|
)
|
||||||
|
result = ffi.string(r)
|
||||||
|
lib.FreeCString(r)
|
||||||
|
print(result.decode("utf-8"))
|
||||||
75
mxsmal/src/pymxutils/mxutils/clearaccount.py
Normal file
75
mxsmal/src/pymxutils/mxutils/clearaccount.py
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
# Copyright (C) 2026 saces@c-base.org
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
import click
|
||||||
|
import json
|
||||||
|
from _pygomx import lib, ffi
|
||||||
|
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
@click.option("-u", "--url", "hs_url", metavar="url", help="homeserver url")
|
||||||
|
@click.option("-t", "--token", "token", metavar="token", help="access token")
|
||||||
|
def clearaccount(hs_url, token):
|
||||||
|
"""remove various things from account"""
|
||||||
|
global _hs_url
|
||||||
|
global _token
|
||||||
|
if hs_url is None and token is None:
|
||||||
|
r = lib.cliv0_mxpassitem(b".mxpass", b"*", b"*", b"*")
|
||||||
|
|
||||||
|
result = ffi.string(r).decode("utf-8")
|
||||||
|
lib.FreeCString(r)
|
||||||
|
|
||||||
|
result_dict = json.loads(result)
|
||||||
|
_hs_url = result_dict["Matrixhost"]
|
||||||
|
_token = result_dict["Token"]
|
||||||
|
else:
|
||||||
|
_hs_url = hs_url
|
||||||
|
_token = token
|
||||||
|
|
||||||
|
r = lib.cliv0_accountinfo(
|
||||||
|
_hs_url.encode(encoding="utf-8"), _token.encode(encoding="utf-8")
|
||||||
|
)
|
||||||
|
|
||||||
|
result = ffi.string(r)
|
||||||
|
lib.FreeCString(r)
|
||||||
|
print(result.decode("utf-8"))
|
||||||
|
|
||||||
|
# r = lib.cliv0_clearaccount(hs_url, token)
|
||||||
|
# result = ffi.string(r)
|
||||||
|
# lib.FreeCString(r)
|
||||||
|
# print(result)
|
||||||
|
|
||||||
|
|
||||||
|
@clearaccount.group()
|
||||||
|
def logout(ctx):
|
||||||
|
"""Logout devices"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@logout.command("others")
|
||||||
|
def logout_others():
|
||||||
|
"""Logout all other devices"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@logout.command("all")
|
||||||
|
def logout_all():
|
||||||
|
"""Logout all devices"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@logout.command("self")
|
||||||
|
def logout_self():
|
||||||
|
"""Logout this device"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@clearaccount.command()
|
||||||
|
def sub1():
|
||||||
|
"""sub1"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@clearaccount.command()
|
||||||
|
def sub2():
|
||||||
|
"""sub2"""
|
||||||
|
pass
|
||||||
22
mxsmal/src/pymxutils/mxutils/serverinfo.py
Normal file
22
mxsmal/src/pymxutils/mxutils/serverinfo.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Copyright (C) 2026 saces@c-base.org
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import click
|
||||||
|
from _pygomx import ffi, lib
|
||||||
|
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.option(
|
||||||
|
"--json", "show_json", is_flag=True, help="show json as returned from server."
|
||||||
|
)
|
||||||
|
@click.argument("domain", metavar="string")
|
||||||
|
def serverinfo(domain, show_json):
|
||||||
|
"""show server info for given server (federationstester light)"""
|
||||||
|
|
||||||
|
mxdomain = sys.argv[1].encode(encoding="utf-8")
|
||||||
|
|
||||||
|
r = lib.cliv0_serverinfo(mxdomain)
|
||||||
|
result = ffi.string(r).decode("utf-8")
|
||||||
|
lib.FreeCString(r)
|
||||||
|
print(result)
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
# Copyright (C) 2026 saces@c-base.org
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
import sys
|
|
||||||
from _pygomx import lib, ffi
|
|
||||||
|
|
||||||
|
|
||||||
def accountinfo():
|
|
||||||
if len(sys.argv) != 3:
|
|
||||||
print("usage: ", sys.argv[0], " url acesstoken")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
url = sys.argv[1].encode(encoding="utf-8")
|
|
||||||
tk = sys.argv[2].encode(encoding="utf-8")
|
|
||||||
|
|
||||||
r = lib.cliv0_accountinfo(url, tk)
|
|
||||||
result = ffi.string(r)
|
|
||||||
lib.FreeCString(r)
|
|
||||||
print(result)
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
# Copyright (C) 2026 saces@c-base.org
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
import sys
|
|
||||||
from _pygomx import lib, ffi
|
|
||||||
|
|
||||||
|
|
||||||
def clearaccount():
|
|
||||||
if len(sys.argv) != 3:
|
|
||||||
print("usage: ", sys.argv[0], " url accesstoken")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
url = sys.argv[1].encode(encoding="utf-8")
|
|
||||||
tk = sys.argv[2].encode(encoding="utf-8")
|
|
||||||
|
|
||||||
r = lib.cliv0_clearaccount(url, tk)
|
|
||||||
result = ffi.string(r)
|
|
||||||
lib.FreeCString(r)
|
|
||||||
print(result)
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
# Copyright (C) 2026 saces@c-base.org
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
import sys
|
|
||||||
from _pygomx import lib, ffi
|
|
||||||
|
|
||||||
|
|
||||||
def serverinfo():
|
|
||||||
if len(sys.argv) != 2:
|
|
||||||
print("usage: ", sys.argv[0], " url|domainname")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
mxdomain = sys.argv[1].encode(encoding="utf-8")
|
|
||||||
|
|
||||||
r = lib.cliv0_serverinfo(mxdomain)
|
|
||||||
result = ffi.string(r).decode("utf-8")
|
|
||||||
lib.FreeCString(r)
|
|
||||||
print(result)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue