diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index dec3305..849eab8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -156,7 +156,7 @@ jobs: env: SOURCE_DATE_EPOCH: ${{ needs.timestamp.outputs.sepoch }} run: | - cd smal/ + cd mxsmal/ pip install build python -m build --sdist pip install ./dist/*.tar.gz @@ -165,7 +165,7 @@ jobs: uses: actions/upload-artifact@v7 with: name: smal-${{ github.sha }}-sdist.zip - path: ./smal/dist/*.tar.gz + path: ./mxsmal/dist/*.tar.gz smal-wheel: @@ -183,7 +183,7 @@ jobs: env: SOURCE_DATE_EPOCH: ${{ needs.timestamp.outputs.sepoch }} run: | - cd smal/ + cd mxsmal/ pip install build python -m build --wheel pip install ./dist/*.whl @@ -192,7 +192,7 @@ jobs: uses: actions/upload-artifact@v7 with: name: smal-${{ github.sha }}-wheel.zip - path: ./smal/dist/*.whl + path: ./mxsmal/dist/*.whl smal-pypi: diff --git a/Containerfile.debian b/Containerfile.debian index 12e3b7e..6a8d6ad 100644 --- a/Containerfile.debian +++ b/Containerfile.debian @@ -49,8 +49,8 @@ EOF RUN --mount=type=bind,from=pybuilder,source=/pygomx-wheel,target=/pygomx-wheel pip install /pygomx-wheel/*.whl FROM develop AS demobot -WORKDIR /smal -COPY smal /smal +WORKDIR /mxsmal +COPY mxsmal /mxsmal RUN pip install . WORKDIR /demobot diff --git a/README.txt b/README.txt index eb961de..7600a46 100644 --- a/README.txt +++ b/README.txt @@ -19,11 +19,8 @@ the bot follows each invite (autojoin) and have two commands: binary/package install: - (only linux-amd64 for now) - pip install --index-url https://codeberg.org/api/packages/saces/pypi/simple/ --no-deps pygomx - pip install git+https://codeberg.org/saces/pygomx.git#subdirectory=pygomx-deps - - pip install git+https://codeberg.org/saces/pygomx.git#subdirectory=smal + pip install pygomx + pip install mxsmal install from source / develop (venv): @@ -45,7 +42,7 @@ install from source / develop (venv): cd pygomx pip install . - cd ../smal + cd ../mxsmal pip install [-e] . usage: diff --git a/compose.yaml b/compose.yaml index 63dda98..b21024c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -4,9 +4,9 @@ services: context: . dockerfile: Containerfile.debian target: develop - working_dir: /smal + working_dir: /mxsmal volumes: - - ./smal:/smal:ro + - ./mxsmal:/mxsmal:ro - ./work:/work demobot: diff --git a/smal/.gitignore b/mxsmal/.gitignore similarity index 100% rename from smal/.gitignore rename to mxsmal/.gitignore diff --git a/smal/README.txt b/mxsmal/README.txt similarity index 93% rename from smal/README.txt rename to mxsmal/README.txt index 6db8081..04aa060 100644 --- a/smal/README.txt +++ b/mxsmal/README.txt @@ -4,7 +4,7 @@ Simple Matrix Application Library sub libs: - pymxutils: matrix cli utils - - smal: the lib itself + - mxsmal: the lib itself - smbl: simplematrixbotlib compat layer experiments (if any) - demobot: simple demo bot diff --git a/smal/pyproject.toml b/mxsmal/pyproject.toml similarity index 94% rename from smal/pyproject.toml rename to mxsmal/pyproject.toml index 9de4382..380d25e 100644 --- a/smal/pyproject.toml +++ b/mxsmal/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ [tool.setuptools.package-dir] "pymxutils" = "src/pymxutils" -"mxsmal" = "src/smal" +"mxsmal" = "src/mxsmal" "smbl" = "src/smbl" "demobot" = "src/demobot" @@ -40,6 +40,6 @@ mxlogout = "pymxutils.mxutils:logout" mxclearaccount = "pymxutils.mxutils:clearaccount" mxserverinfo = "pymxutils.mxutils:serverinfo" mxpassitem = "pymxutils.mxutils:passitem" -smalsetup = "smal.smalsetup:smalsetup" +smalsetup = "mxsmal.smalsetup:smalsetup" demobot = "demobot:main" simplebot = "demobot.simple:main" diff --git a/smal/setup.py b/mxsmal/setup.py similarity index 100% rename from smal/setup.py rename to mxsmal/setup.py diff --git a/smal/src/demobot/__init__.py b/mxsmal/src/demobot/__init__.py similarity index 100% rename from smal/src/demobot/__init__.py rename to mxsmal/src/demobot/__init__.py diff --git a/smal/src/demobot/__main__.py b/mxsmal/src/demobot/__main__.py similarity index 100% rename from smal/src/demobot/__main__.py rename to mxsmal/src/demobot/__main__.py diff --git a/smal/src/demobot/demobot.py b/mxsmal/src/demobot/demobot.py similarity index 98% rename from smal/src/demobot/demobot.py rename to mxsmal/src/demobot/demobot.py index 80a550c..d5a1aaa 100644 --- a/smal/src/demobot/demobot.py +++ b/mxsmal/src/demobot/demobot.py @@ -1,7 +1,7 @@ # Copyright (C) 2026 saces@c-base.org # SPDX-License-Identifier: AGPL-3.0-only import logging -from smal.bot import SMALBot +from mxsmal.bot import SMALBot # setup logging, we want timestamps logging.basicConfig( diff --git a/smal/src/demobot/simple/__init__.py b/mxsmal/src/demobot/simple/__init__.py similarity index 100% rename from smal/src/demobot/simple/__init__.py rename to mxsmal/src/demobot/simple/__init__.py diff --git a/smal/src/demobot/simple/__main__.py b/mxsmal/src/demobot/simple/__main__.py similarity index 100% rename from smal/src/demobot/simple/__main__.py rename to mxsmal/src/demobot/simple/__main__.py diff --git a/smal/src/demobot/simple/demobot.py b/mxsmal/src/demobot/simple/demobot.py similarity index 98% rename from smal/src/demobot/simple/demobot.py rename to mxsmal/src/demobot/simple/demobot.py index d059f12..42bf070 100644 --- a/smal/src/demobot/simple/demobot.py +++ b/mxsmal/src/demobot/simple/demobot.py @@ -1,7 +1,7 @@ # Copyright (C) 2026 saces@c-base.org # SPDX-License-Identifier: AGPL-3.0-only import logging -from smal.simple.bot import SMALBot +from mxsmal.simple.bot import SMALBot # setup logging, we want timestamps logging.basicConfig( diff --git a/smal/src/smal/__init__.py b/mxsmal/src/mxsmal/__init__.py similarity index 100% rename from smal/src/smal/__init__.py rename to mxsmal/src/mxsmal/__init__.py diff --git a/smal/src/smal/app.py b/mxsmal/src/mxsmal/app.py similarity index 100% rename from smal/src/smal/app.py rename to mxsmal/src/mxsmal/app.py diff --git a/smal/src/smal/bot.py b/mxsmal/src/mxsmal/bot.py similarity index 100% rename from smal/src/smal/bot.py rename to mxsmal/src/mxsmal/bot.py diff --git a/smal/src/smal/py.typed b/mxsmal/src/mxsmal/py.typed similarity index 100% rename from smal/src/smal/py.typed rename to mxsmal/src/mxsmal/py.typed diff --git a/smal/src/smal/simple/app.py b/mxsmal/src/mxsmal/simple/app.py similarity index 100% rename from smal/src/smal/simple/app.py rename to mxsmal/src/mxsmal/simple/app.py diff --git a/smal/src/smal/simple/bot.py b/mxsmal/src/mxsmal/simple/bot.py similarity index 100% rename from smal/src/smal/simple/bot.py rename to mxsmal/src/mxsmal/simple/bot.py diff --git a/smal/src/smal/smalsetup/__init__.py b/mxsmal/src/mxsmal/smalsetup/__init__.py similarity index 100% rename from smal/src/smal/smalsetup/__init__.py rename to mxsmal/src/mxsmal/smalsetup/__init__.py diff --git a/smal/src/smal/smalsetup/__main__.py b/mxsmal/src/mxsmal/smalsetup/__main__.py similarity index 100% rename from smal/src/smal/smalsetup/__main__.py rename to mxsmal/src/mxsmal/smalsetup/__main__.py diff --git a/smal/src/smal/smalsetup/smalsetup.py b/mxsmal/src/mxsmal/smalsetup/smalsetup.py similarity index 100% rename from smal/src/smal/smalsetup/smalsetup.py rename to mxsmal/src/mxsmal/smalsetup/smalsetup.py diff --git a/smal/src/pymxutils/mxutils/__init__.py b/mxsmal/src/pymxutils/mxutils/__init__.py similarity index 100% rename from smal/src/pymxutils/mxutils/__init__.py rename to mxsmal/src/pymxutils/mxutils/__init__.py diff --git a/mxsmal/src/pymxutils/mxutils/accountinfo.py b/mxsmal/src/pymxutils/mxutils/accountinfo.py new file mode 100644 index 0000000..43e880a --- /dev/null +++ b/mxsmal/src/pymxutils/mxutils/accountinfo.py @@ -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")) diff --git a/mxsmal/src/pymxutils/mxutils/clearaccount.py b/mxsmal/src/pymxutils/mxutils/clearaccount.py new file mode 100644 index 0000000..9f17945 --- /dev/null +++ b/mxsmal/src/pymxutils/mxutils/clearaccount.py @@ -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 diff --git a/smal/src/pymxutils/mxutils/click.py b/mxsmal/src/pymxutils/mxutils/click.py similarity index 100% rename from smal/src/pymxutils/mxutils/click.py rename to mxsmal/src/pymxutils/mxutils/click.py diff --git a/smal/src/pymxutils/mxutils/discoverhs.py b/mxsmal/src/pymxutils/mxutils/discoverhs.py similarity index 100% rename from smal/src/pymxutils/mxutils/discoverhs.py rename to mxsmal/src/pymxutils/mxutils/discoverhs.py diff --git a/smal/src/pymxutils/mxutils/logout.py b/mxsmal/src/pymxutils/mxutils/logout.py similarity index 100% rename from smal/src/pymxutils/mxutils/logout.py rename to mxsmal/src/pymxutils/mxutils/logout.py diff --git a/smal/src/pymxutils/mxutils/mktoken.py b/mxsmal/src/pymxutils/mxutils/mktoken.py similarity index 100% rename from smal/src/pymxutils/mxutils/mktoken.py rename to mxsmal/src/pymxutils/mxutils/mktoken.py diff --git a/smal/src/pymxutils/mxutils/passitem.py b/mxsmal/src/pymxutils/mxutils/passitem.py similarity index 100% rename from smal/src/pymxutils/mxutils/passitem.py rename to mxsmal/src/pymxutils/mxutils/passitem.py diff --git a/mxsmal/src/pymxutils/mxutils/serverinfo.py b/mxsmal/src/pymxutils/mxutils/serverinfo.py new file mode 100644 index 0000000..b008448 --- /dev/null +++ b/mxsmal/src/pymxutils/mxutils/serverinfo.py @@ -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) diff --git a/smal/src/pymxutils/mxutils/whoami.py b/mxsmal/src/pymxutils/mxutils/whoami.py similarity index 100% rename from smal/src/pymxutils/mxutils/whoami.py rename to mxsmal/src/pymxutils/mxutils/whoami.py diff --git a/smal/src/smbl/__init__.py b/mxsmal/src/smbl/__init__.py similarity index 100% rename from smal/src/smbl/__init__.py rename to mxsmal/src/smbl/__init__.py diff --git a/smal/src/pymxutils/mxutils/accountinfo.py b/smal/src/pymxutils/mxutils/accountinfo.py deleted file mode 100644 index 97ec46f..0000000 --- a/smal/src/pymxutils/mxutils/accountinfo.py +++ /dev/null @@ -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) diff --git a/smal/src/pymxutils/mxutils/clearaccount.py b/smal/src/pymxutils/mxutils/clearaccount.py deleted file mode 100644 index 63a8626..0000000 --- a/smal/src/pymxutils/mxutils/clearaccount.py +++ /dev/null @@ -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) diff --git a/smal/src/pymxutils/mxutils/serverinfo.py b/smal/src/pymxutils/mxutils/serverinfo.py deleted file mode 100644 index bce9aec..0000000 --- a/smal/src/pymxutils/mxutils/serverinfo.py +++ /dev/null @@ -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)