Update
This commit is contained in:
parent
329516375f
commit
3b9852d9a6
8
SETUP.md
8
SETUP.md
|
@ -77,20 +77,22 @@ Install python dependencies:
|
|||
|
||||
```
|
||||
pip install -e .
|
||||
# Using requirements.txt
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
This projects uses [Wand](https://docs.wand-py.org) and requires you to install ImageMagick library.
|
||||
This project uses [Wand](https://docs.wand-py.org) and the `pango-view` CLI command, requiring you to install ImageMagick library and Pango CLI tools.
|
||||
|
||||
Debian/Ubuntu:
|
||||
|
||||
```
|
||||
sudo apt install libmagickwand-dev
|
||||
sudo apt install libmagickwand-dev pango1.0-tools
|
||||
```
|
||||
|
||||
Arch:
|
||||
|
||||
```
|
||||
sudo pacman -S imagemagick
|
||||
sudo pacman -S imagemagick pango
|
||||
```
|
||||
|
||||
(Optional) If you want to use postgres as a database backend, use the following
|
||||
|
|
15
nyx-bot
15
nyx-bot
|
@ -1,15 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import logging
|
||||
import nyx_bot
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
from nyx_bot import main
|
||||
|
||||
# Run the main function of the bot
|
||||
asyncio.get_event_loop().run_until_complete(main.main())
|
||||
except ImportError as e:
|
||||
print("Unable to import nyx_box.main:", e)
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Bye!")
|
||||
nyx_bot.run()
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
|
||||
# Check that we're not running on an unsupported Python version.
|
||||
|
@ -5,4 +7,16 @@ if sys.version_info < (3, 5):
|
|||
print("nyx_bot requires Python 3.5 or above.")
|
||||
sys.exit(1)
|
||||
|
||||
__version__ = "0.0.1"
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run():
|
||||
try:
|
||||
from . import main
|
||||
|
||||
# Run the main function of the bot
|
||||
asyncio.get_event_loop().run_until_complete(main.main())
|
||||
except ImportError as e:
|
||||
print("Unable to import nyx_box.main:", e)
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Bye!")
|
||||
|
|
|
@ -110,6 +110,7 @@ class Config:
|
|||
|
||||
self.disable_jerryxiao_for = self._get_cfg(["disable_jerryxiao_for"], [])
|
||||
self.disable_randomdraw_for = self._get_cfg(["disable_randomdraw_for"], [])
|
||||
self.encryption = self._get_cfg(["encryption"], False)
|
||||
|
||||
def _get_cfg(
|
||||
self,
|
||||
|
|
|
@ -69,7 +69,7 @@ async def main():
|
|||
max_timeouts=0,
|
||||
store=DefaultStore,
|
||||
store_sync_tokens=True,
|
||||
encryption_enabled=False,
|
||||
encryption_enabled=config.encryption,
|
||||
)
|
||||
|
||||
# Initialize the matrix client
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "nyx-bot"
|
||||
version = "0.0.1"
|
||||
description = "A matrix bot to do amazing things!"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.5"
|
||||
dependencies = [
|
||||
"matrix-nio>=0.10.0",
|
||||
"Markdown>=3.1.1",
|
||||
"PyYAML>=5.1.2",
|
||||
"Wand",
|
||||
"python-magic",
|
||||
"peewee",
|
||||
"python-dateutil",
|
||||
]
|
||||
classifiers=[
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
postgres = ["psycopg2>=2.8.5"]
|
||||
dev = [
|
||||
"isort==5.0.4",
|
||||
"flake8==3.8.3",
|
||||
"flake8-comprehensions==3.2.3",
|
||||
"black==22.6.0",
|
||||
]
|
||||
e2e = ["matrix-nio[e2e]>=0.10.0"]
|
||||
|
||||
[project.scripts]
|
||||
nyx-bot = "nyx_bot:run"
|
||||
|
||||
# Setuptools
|
||||
[tool.setuptools]
|
||||
packages = ["nyx_bot"]
|
|
@ -0,0 +1,2 @@
|
|||
-r requirements.txt
|
||||
matrix-nio[e2e]>=0.10.0
|
|
@ -0,0 +1,2 @@
|
|||
-r requirements.txt
|
||||
psycopg2>=2.8.5
|
|
@ -5,6 +5,9 @@
|
|||
# The string to prefix messages with to talk to the bot in group chats
|
||||
command_prefix: "!c"
|
||||
|
||||
# Enable E2EE room support ?
|
||||
encryption: False
|
||||
|
||||
# Options for connecting to the bot's Matrix account
|
||||
matrix:
|
||||
# The Matrix User ID of the bot account
|
||||
|
|
63
setup.py
63
setup.py
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
|
||||
def exec_file(path_segments):
|
||||
"""Execute a single python file to get the variables defined in it"""
|
||||
result = {}
|
||||
code = read_file(path_segments)
|
||||
exec(code, result)
|
||||
return result
|
||||
|
||||
|
||||
def read_file(path_segments):
|
||||
"""Read a file from the package. Takes a list of strings to join to
|
||||
make the path"""
|
||||
file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *path_segments)
|
||||
with open(file_path) as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
version = exec_file(("nyx_bot", "__init__.py"))["__version__"]
|
||||
long_description = read_file(("README.md",))
|
||||
|
||||
|
||||
setup(
|
||||
name="nyx-bot",
|
||||
version=version,
|
||||
url="https://github.com/ShadowRZ/nyx-bot",
|
||||
description="A matrix bot to do amazing things!",
|
||||
packages=find_packages(exclude=["tests", "tests.*"]),
|
||||
install_requires=[
|
||||
"matrix-nio[e2e]>=0.10.0",
|
||||
"Markdown>=3.1.1",
|
||||
"PyYAML>=5.1.2",
|
||||
"Wand",
|
||||
"python-magic",
|
||||
"peewee",
|
||||
"python-dateutil",
|
||||
],
|
||||
extras_require={
|
||||
"postgres": ["psycopg2>=2.8.5"],
|
||||
"dev": [
|
||||
"isort==5.0.4",
|
||||
"flake8==3.8.3",
|
||||
"flake8-comprehensions==3.2.3",
|
||||
"black==22.6.0",
|
||||
],
|
||||
},
|
||||
classifiers=[
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
],
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
# Allow the user to run the bot with `nyx-bot ...`
|
||||
scripts=["nyx-bot"],
|
||||
)
|
Loading…
Reference in New Issue