matrix-bot: Init working sending and receiving

This commit is contained in:
Luis Hebendanz 2024-06-27 18:21:20 +02:00
parent eaa489319b
commit 81a7bba6a6
4 changed files with 33 additions and 19 deletions

View File

@ -1,17 +1,17 @@
{ python3, setuptools, mautrix, ... }:
{
python3,
setuptools,
matrix-nio,
...
}:
let
pythonDependencies = [
mautrix
];
pythonDependencies = [ matrix-nio ];
runtimeDependencies = [ ];
testDependencies =
runtimeDependencies ++ [
];
testDependencies = pythonDependencies ++ runtimeDependencies ++ [ ];
in
python3.pkgs.buildPythonApplication {
@ -19,9 +19,7 @@ python3.pkgs.buildPythonApplication {
src = ./.;
format = "pyproject";
nativeBuildInputs = [
setuptools
];
nativeBuildInputs = [ setuptools ];
propagatedBuildInputs = pythonDependencies;

View File

@ -1,4 +1,4 @@
from .main import main
if __name__ == "__main__":
main()
main()

View File

@ -1,4 +1,4 @@
from .main import main
if __name__ == "__main__":
main()
main()

View File

@ -1,7 +1,8 @@
import argparse
import asyncio
import logging
import sys
from matrix_bot.bot import bot_main
from matrix_bot.custom_logger import setup_logging
log = logging.getLogger(__name__)
@ -21,16 +22,31 @@ def create_parser(prog: str | None = None) -> argparse.ArgumentParser:
default=False,
)
parser.add_argument(
"--server",
help="The matrix server to connect to",
default="https://matrix.clan.lol",
required=True,
)
parser.add_argument(
"--user",
help="The matrix user to connect as",
default="@clan-bot:clan.lol",
required=True,
)
return parser
def main():
def main() -> None:
parser = create_parser()
args = parser.parse_args()
if len(sys.argv) == 1:
parser.print_help()
if args.debug:
setup_logging(logging.DEBUG, root_log_name=__name__.split(".")[0])
log.debug("Debug log activated")
else:
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])
asyncio.run(bot_main(args.server, args.user))