mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono-python.git
synced 2024-09-27 18:56:20 +08:00
Compare commits
2 Commits
87d35c9c41
...
a716b4f5d8
Author | SHA1 | Date | |
---|---|---|---|
a716b4f5d8 | |||
becbef1540 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,5 +6,5 @@ __run__/
|
|||||||
.vscode/*
|
.vscode/*
|
||||||
|
|
||||||
# python toolchain auto-generated
|
# python toolchain auto-generated
|
||||||
|
.venv/
|
||||||
**__pycache__
|
**__pycache__
|
||||||
poetry.lock
|
|
||||||
|
7
__main__.py
Normal file
7
__main__.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from morny import server_main
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
server_main.main()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -1,7 +1,7 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from define import Coeur_Def
|
from morny.define import Coeur_Def
|
||||||
from .log import *
|
from .log import *
|
||||||
|
|
||||||
if Coeur_Def.is_file_logging() :
|
if Coeur_Def.is_file_logging() :
|
||||||
|
7
morny/__main__.py
Normal file
7
morny/__main__.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from morny import server_main
|
||||||
|
|
||||||
|
def main():
|
||||||
|
server_main.main()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -1,12 +1,11 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
class Coeur_Def :
|
class Coeur_Def :
|
||||||
'''Morny Coeur python 程序以及当前的版本的元信息'''
|
'''Morny Coeur python 程序以及当前的版本的元信息'''
|
||||||
|
|
||||||
VERSION = "0.1+coeur0.7.2.1"
|
VERSION = "0.1.1+coeur0.7.2.1"
|
||||||
CODE = "fuzhou"
|
CODE = "fuzhou"
|
||||||
TIMETAG = "2209261500"
|
TIMETAG = "2209272250"
|
||||||
|
|
||||||
def is_file_logging () -> bool :
|
def is_file_logging () -> bool :
|
||||||
return os.getenv ("MORNY_LOGGING_TO_FILE") == "true"
|
return os.getenv ("MORNY_LOGGING_TO_FILE") == "true"
|
133
morny/server_main.py
Normal file
133
morny/server_main.py
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
from morny.define import Coeur_Def
|
||||||
|
from logger.logger import *
|
||||||
|
from morny.morny_hello import morny_hello_text
|
||||||
|
|
||||||
|
thread_morny_init = "morny-init"
|
||||||
|
prop_name_token_tg_key = "TELEGRAM_BOT_API_TOKEN"
|
||||||
|
prop_name_token_morny_key = "MORNY_TG_TOKEN"
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## 启动参数的声明
|
||||||
|
|
||||||
|
versionEchoMode:bool = False
|
||||||
|
welcomeEchoMode:bool = False
|
||||||
|
showWelcome:bool = True
|
||||||
|
key:str|None = None
|
||||||
|
username:str|None = None;
|
||||||
|
outdatedBlock:bool = False
|
||||||
|
master:int = 793274677
|
||||||
|
trustedReadersOfDinner:set = set()
|
||||||
|
trustedChat:int = -1001541451710
|
||||||
|
autoCmdList:bool = False
|
||||||
|
autoCmdRemove:bool = False
|
||||||
|
api:str|None = None
|
||||||
|
api4File:str|None = None
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## 从命令行与环境变量读取启动参数值
|
||||||
|
|
||||||
|
i = 1;
|
||||||
|
while (i < len(sys.argv)) :
|
||||||
|
|
||||||
|
if (sys.argv[i].startswith("-")):
|
||||||
|
|
||||||
|
match sys.argv[i] :
|
||||||
|
case "--outdated-block" | "-ob" :
|
||||||
|
outdatedBlock = True
|
||||||
|
i+=1;continue
|
||||||
|
case "--no-hello" | "-hf" | "--quiet" | "-q" :
|
||||||
|
showWelcome = False
|
||||||
|
i+=1;continue
|
||||||
|
case "--only-hello" | "-ho" | "-o" | "-hi" :
|
||||||
|
welcomeEchoMode = True
|
||||||
|
i+=1;continue
|
||||||
|
case "--version" | "-v" :
|
||||||
|
versionEchoMode = True
|
||||||
|
i+=1;continue
|
||||||
|
case "--token" | "-t" :
|
||||||
|
i+=1; key = sys.argv[i]
|
||||||
|
i+=1;continue
|
||||||
|
case "--username" | "-u" :
|
||||||
|
i+=1; username = sys.argv[i]
|
||||||
|
i+=1;continue
|
||||||
|
case "--master" | "-mm" :
|
||||||
|
i+=1; master = int(sys.argv[i])
|
||||||
|
i+=1;continue
|
||||||
|
case "--trusted-chat" | "-trs" :
|
||||||
|
i+=1; trustedChat = int(sys.argv[i])
|
||||||
|
i+=1;continue
|
||||||
|
case "--trusted-reader-dinner" | "-trsd" :
|
||||||
|
i+=1; trustedReadersOfDinner.add(int(sys.argv[i]))
|
||||||
|
i+=1;continue
|
||||||
|
case "--auto-cmd" | "-cmd" | "-c" :
|
||||||
|
autoCmdList = True
|
||||||
|
autoCmdRemove = True
|
||||||
|
i+=1;continue
|
||||||
|
case "--auto-cmd-list" | "-ca" :
|
||||||
|
autoCmdList = True
|
||||||
|
i+=1;continue
|
||||||
|
case "--auto-cmd-remove" | "-cr" :
|
||||||
|
autoCmdRemove = True
|
||||||
|
i+=1;continue
|
||||||
|
case "--api" | "-a" :
|
||||||
|
i+=1; api = sys.argv[i]
|
||||||
|
i+=1;continue
|
||||||
|
case "--api-files" | "files-api" | "-af" :
|
||||||
|
i+=1; api4File = sys.argv[i]
|
||||||
|
i+=1;continue
|
||||||
|
|
||||||
|
warn(f"Can't understand arg to some meaning :\n {sys.argv[i]}")
|
||||||
|
i+=1
|
||||||
|
|
||||||
|
|
||||||
|
'''从系统环境变量设置的 bot token 值'''
|
||||||
|
propToken:str|None = None
|
||||||
|
'''表明 bot token 值的来源是哪个系统环境变量'''
|
||||||
|
propTokenKey:str|None = None
|
||||||
|
|
||||||
|
for iKey in [prop_name_token_tg_key, prop_name_token_morny_key] :
|
||||||
|
if (os.getenv(iKey) != None) :
|
||||||
|
propToken = os.getenv(iKey)
|
||||||
|
propTokenKey = iKey
|
||||||
|
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## 启动参数的检查和处理
|
||||||
|
|
||||||
|
if versionEchoMode :
|
||||||
|
info(f"""Morny Cono Version
|
||||||
|
- version :
|
||||||
|
{Coeur_Def.VERSION} {Coeur_Def.CODE.upper()}
|
||||||
|
- md5hash :
|
||||||
|
<unavailable_in_python_implementation>
|
||||||
|
- rw.time :
|
||||||
|
{Coeur_Def.TIMETAG} [UTC+8]"""
|
||||||
|
); exit()
|
||||||
|
|
||||||
|
if showWelcome : info(morny_hello_text())
|
||||||
|
if welcomeEchoMode : exit()
|
||||||
|
|
||||||
|
info(f"""morny/server_main.py Executed >>>
|
||||||
|
- version {Coeur_Def.VERSION} [{Coeur_Def.TIMETAG}]
|
||||||
|
- Morny {Coeur_Def.CODE.upper()}""")
|
||||||
|
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## Coeur 参数检查以及正式呼叫主程序
|
||||||
|
|
||||||
|
if (propToken != None) :
|
||||||
|
key = propToken
|
||||||
|
info(f"Parameter <token> set by EnvVar ${propTokenKey}")
|
||||||
|
if (key == None) :
|
||||||
|
info("Parameter required has no value:\n --token.")
|
||||||
|
exit()
|
||||||
|
threading.current_thread().name = thread_morny_init
|
||||||
|
#todo call coeur main
|
223
poetry.lock
generated
Normal file
223
poetry.lock
generated
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand.
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "apscheduler"
|
||||||
|
version = "3.6.3"
|
||||||
|
description = "In-process task scheduler with Cron-like capabilities"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
files = [
|
||||||
|
{file = "APScheduler-3.6.3-py2.py3-none-any.whl", hash = "sha256:e8b1ecdb4c7cb2818913f766d5898183c7cb8936680710a4d3a966e02262e526"},
|
||||||
|
{file = "APScheduler-3.6.3.tar.gz", hash = "sha256:3bb5229eed6fbbdafc13ce962712ae66e175aa214c69bed35a06bffcf0c5e244"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
pytz = "*"
|
||||||
|
setuptools = ">=0.7"
|
||||||
|
six = ">=1.4.0"
|
||||||
|
tzlocal = ">=1.2"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
asyncio = ["trollius"]
|
||||||
|
doc = ["sphinx", "sphinx-rtd-theme"]
|
||||||
|
gevent = ["gevent"]
|
||||||
|
mongodb = ["pymongo (>=2.8)"]
|
||||||
|
redis = ["redis (>=3.0)"]
|
||||||
|
rethinkdb = ["rethinkdb (>=2.4.0)"]
|
||||||
|
sqlalchemy = ["sqlalchemy (>=0.8)"]
|
||||||
|
testing = ["mock", "pytest", "pytest-asyncio", "pytest-asyncio (<0.6)", "pytest-cov", "pytest-tornado5"]
|
||||||
|
tornado = ["tornado (>=4.3)"]
|
||||||
|
twisted = ["twisted"]
|
||||||
|
zookeeper = ["kazoo"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cachetools"
|
||||||
|
version = "4.2.2"
|
||||||
|
description = "Extensible memoizing collections and decorators"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "~=3.5"
|
||||||
|
files = [
|
||||||
|
{file = "cachetools-4.2.2-py3-none-any.whl", hash = "sha256:2cc0b89715337ab6dbba85b5b50effe2b0c74e035d83ee8ed637cf52f12ae001"},
|
||||||
|
{file = "cachetools-4.2.2.tar.gz", hash = "sha256:61b5ed1e22a0924aed1d23b478f37e8d52549ff8a961de2909c69bf950020cff"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "certifi"
|
||||||
|
version = "2022.12.7"
|
||||||
|
description = "Python package for providing Mozilla's CA Bundle."
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6"
|
||||||
|
files = [
|
||||||
|
{file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"},
|
||||||
|
{file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "python-telegram-bot"
|
||||||
|
version = "13.15"
|
||||||
|
description = "We have made you a wrapper you can't refuse"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
files = [
|
||||||
|
{file = "python-telegram-bot-13.15.tar.gz", hash = "sha256:b4047606b8081b62bbd6aa361f7ca1efe87fa8f1881ec9d932d35844bf57a154"},
|
||||||
|
{file = "python_telegram_bot-13.15-py3-none-any.whl", hash = "sha256:06780c258d3f2a3c6c79a7aeb45714f4cd1dd6275941b7dc4628bba64fddd465"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
APScheduler = "3.6.3"
|
||||||
|
cachetools = "4.2.2"
|
||||||
|
certifi = "*"
|
||||||
|
pytz = ">=2018.6"
|
||||||
|
tornado = "6.1"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
json = ["ujson"]
|
||||||
|
passport = ["cryptography (!=3.4,!=3.4.1,!=3.4.2,!=3.4.3)"]
|
||||||
|
socks = ["PySocks"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pytz"
|
||||||
|
version = "2023.3"
|
||||||
|
description = "World timezone definitions, modern and historical"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
files = [
|
||||||
|
{file = "pytz-2023.3-py2.py3-none-any.whl", hash = "sha256:a151b3abb88eda1d4e34a9814df37de2a80e301e68ba0fd856fb9b46bfbbbffb"},
|
||||||
|
{file = "pytz-2023.3.tar.gz", hash = "sha256:1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pytz-deprecation-shim"
|
||||||
|
version = "0.1.0.post0"
|
||||||
|
description = "Shims to make deprecation of pytz easier"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7"
|
||||||
|
files = [
|
||||||
|
{file = "pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl", hash = "sha256:8314c9692a636c8eb3bda879b9f119e350e93223ae83e70e80c31675a0fdc1a6"},
|
||||||
|
{file = "pytz_deprecation_shim-0.1.0.post0.tar.gz", hash = "sha256:af097bae1b616dde5c5744441e2ddc69e74dfdcb0c263129610d85b87445a59d"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
tzdata = {version = "*", markers = "python_version >= \"3.6\""}
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "setuptools"
|
||||||
|
version = "67.7.2"
|
||||||
|
description = "Easily download, build, install, upgrade, and uninstall Python packages"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
files = [
|
||||||
|
{file = "setuptools-67.7.2-py3-none-any.whl", hash = "sha256:23aaf86b85ca52ceb801d32703f12d77517b2556af839621c641fca11287952b"},
|
||||||
|
{file = "setuptools-67.7.2.tar.gz", hash = "sha256:f104fa03692a2602fa0fec6c6a9e63b6c8a968de13e17c026957dd1f53d80990"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"]
|
||||||
|
testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"]
|
||||||
|
testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "six"
|
||||||
|
version = "1.16.0"
|
||||||
|
description = "Python 2 and 3 compatibility utilities"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||||
|
files = [
|
||||||
|
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||||
|
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tornado"
|
||||||
|
version = "6.1"
|
||||||
|
description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed."
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">= 3.5"
|
||||||
|
files = [
|
||||||
|
{file = "tornado-6.1-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:d371e811d6b156d82aa5f9a4e08b58debf97c302a35714f6f45e35139c332e32"},
|
||||||
|
{file = "tornado-6.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:0d321a39c36e5f2c4ff12b4ed58d41390460f798422c4504e09eb5678e09998c"},
|
||||||
|
{file = "tornado-6.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:9de9e5188a782be6b1ce866e8a51bc76a0fbaa0e16613823fc38e4fc2556ad05"},
|
||||||
|
{file = "tornado-6.1-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:61b32d06ae8a036a6607805e6720ef00a3c98207038444ba7fd3d169cd998910"},
|
||||||
|
{file = "tornado-6.1-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:3e63498f680547ed24d2c71e6497f24bca791aca2fe116dbc2bd0ac7f191691b"},
|
||||||
|
{file = "tornado-6.1-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:6c77c9937962577a6a76917845d06af6ab9197702a42e1346d8ae2e76b5e3675"},
|
||||||
|
{file = "tornado-6.1-cp35-cp35m-win32.whl", hash = "sha256:6286efab1ed6e74b7028327365cf7346b1d777d63ab30e21a0f4d5b275fc17d5"},
|
||||||
|
{file = "tornado-6.1-cp35-cp35m-win_amd64.whl", hash = "sha256:fa2ba70284fa42c2a5ecb35e322e68823288a4251f9ba9cc77be04ae15eada68"},
|
||||||
|
{file = "tornado-6.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:0a00ff4561e2929a2c37ce706cb8233b7907e0cdc22eab98888aca5dd3775feb"},
|
||||||
|
{file = "tornado-6.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:748290bf9112b581c525e6e6d3820621ff020ed95af6f17fedef416b27ed564c"},
|
||||||
|
{file = "tornado-6.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:e385b637ac3acaae8022e7e47dfa7b83d3620e432e3ecb9a3f7f58f150e50921"},
|
||||||
|
{file = "tornado-6.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:25ad220258349a12ae87ede08a7b04aca51237721f63b1808d39bdb4b2164558"},
|
||||||
|
{file = "tornado-6.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:65d98939f1a2e74b58839f8c4dab3b6b3c1ce84972ae712be02845e65391ac7c"},
|
||||||
|
{file = "tornado-6.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:e519d64089b0876c7b467274468709dadf11e41d65f63bba207e04217f47c085"},
|
||||||
|
{file = "tornado-6.1-cp36-cp36m-win32.whl", hash = "sha256:b87936fd2c317b6ee08a5741ea06b9d11a6074ef4cc42e031bc6403f82a32575"},
|
||||||
|
{file = "tornado-6.1-cp36-cp36m-win_amd64.whl", hash = "sha256:cc0ee35043162abbf717b7df924597ade8e5395e7b66d18270116f8745ceb795"},
|
||||||
|
{file = "tornado-6.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:7250a3fa399f08ec9cb3f7b1b987955d17e044f1ade821b32e5f435130250d7f"},
|
||||||
|
{file = "tornado-6.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:ed3ad863b1b40cd1d4bd21e7498329ccaece75db5a5bf58cd3c9f130843e7102"},
|
||||||
|
{file = "tornado-6.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:dcef026f608f678c118779cd6591c8af6e9b4155c44e0d1bc0c87c036fb8c8c4"},
|
||||||
|
{file = "tornado-6.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:70dec29e8ac485dbf57481baee40781c63e381bebea080991893cd297742b8fd"},
|
||||||
|
{file = "tornado-6.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:d3f7594930c423fd9f5d1a76bee85a2c36fd8b4b16921cae7e965f22575e9c01"},
|
||||||
|
{file = "tornado-6.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:3447475585bae2e77ecb832fc0300c3695516a47d46cefa0528181a34c5b9d3d"},
|
||||||
|
{file = "tornado-6.1-cp37-cp37m-win32.whl", hash = "sha256:e7229e60ac41a1202444497ddde70a48d33909e484f96eb0da9baf8dc68541df"},
|
||||||
|
{file = "tornado-6.1-cp37-cp37m-win_amd64.whl", hash = "sha256:cb5ec8eead331e3bb4ce8066cf06d2dfef1bfb1b2a73082dfe8a161301b76e37"},
|
||||||
|
{file = "tornado-6.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:20241b3cb4f425e971cb0a8e4ffc9b0a861530ae3c52f2b0434e6c1b57e9fd95"},
|
||||||
|
{file = "tornado-6.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:c77da1263aa361938476f04c4b6c8916001b90b2c2fdd92d8d535e1af48fba5a"},
|
||||||
|
{file = "tornado-6.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:fba85b6cd9c39be262fcd23865652920832b61583de2a2ca907dbd8e8a8c81e5"},
|
||||||
|
{file = "tornado-6.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:1e8225a1070cd8eec59a996c43229fe8f95689cb16e552d130b9793cb570a288"},
|
||||||
|
{file = "tornado-6.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:d14d30e7f46a0476efb0deb5b61343b1526f73ebb5ed84f23dc794bdb88f9d9f"},
|
||||||
|
{file = "tornado-6.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:8f959b26f2634a091bb42241c3ed8d3cedb506e7c27b8dd5c7b9f745318ddbb6"},
|
||||||
|
{file = "tornado-6.1-cp38-cp38-win32.whl", hash = "sha256:34ca2dac9e4d7afb0bed4677512e36a52f09caa6fded70b4e3e1c89dbd92c326"},
|
||||||
|
{file = "tornado-6.1-cp38-cp38-win_amd64.whl", hash = "sha256:6196a5c39286cc37c024cd78834fb9345e464525d8991c21e908cc046d1cc02c"},
|
||||||
|
{file = "tornado-6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f0ba29bafd8e7e22920567ce0d232c26d4d47c8b5cf4ed7b562b5db39fa199c5"},
|
||||||
|
{file = "tornado-6.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:33892118b165401f291070100d6d09359ca74addda679b60390b09f8ef325ffe"},
|
||||||
|
{file = "tornado-6.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:7da13da6f985aab7f6f28debab00c67ff9cbacd588e8477034c0652ac141feea"},
|
||||||
|
{file = "tornado-6.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:e0791ac58d91ac58f694d8d2957884df8e4e2f6687cdf367ef7eb7497f79eaa2"},
|
||||||
|
{file = "tornado-6.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:66324e4e1beede9ac79e60f88de548da58b1f8ab4b2f1354d8375774f997e6c0"},
|
||||||
|
{file = "tornado-6.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:a48900ecea1cbb71b8c71c620dee15b62f85f7c14189bdeee54966fbd9a0c5bd"},
|
||||||
|
{file = "tornado-6.1-cp39-cp39-win32.whl", hash = "sha256:d3d20ea5782ba63ed13bc2b8c291a053c8d807a8fa927d941bd718468f7b950c"},
|
||||||
|
{file = "tornado-6.1-cp39-cp39-win_amd64.whl", hash = "sha256:548430be2740e327b3fe0201abe471f314741efcb0067ec4f2d7dcfb4825f3e4"},
|
||||||
|
{file = "tornado-6.1.tar.gz", hash = "sha256:33c6e81d7bd55b468d2e793517c909b139960b6c790a60b7991b9b6b76fb9791"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tzdata"
|
||||||
|
version = "2023.3"
|
||||||
|
description = "Provider of IANA time zone data"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=2"
|
||||||
|
files = [
|
||||||
|
{file = "tzdata-2023.3-py2.py3-none-any.whl", hash = "sha256:7e65763eef3120314099b6939b5546db7adce1e7d6f2e179e3df563c70511eda"},
|
||||||
|
{file = "tzdata-2023.3.tar.gz", hash = "sha256:11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tzlocal"
|
||||||
|
version = "4.3"
|
||||||
|
description = "tzinfo object for the local timezone"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
files = [
|
||||||
|
{file = "tzlocal-4.3-py3-none-any.whl", hash = "sha256:b44c4388f3d34f25862cfbb387578a4d70fec417649da694a132f628a23367e2"},
|
||||||
|
{file = "tzlocal-4.3.tar.gz", hash = "sha256:3f21d09e1b2aa9f2dacca12da240ca37de3ba5237a93addfd6d593afe9073355"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
pytz-deprecation-shim = "*"
|
||||||
|
tzdata = {version = "*", markers = "platform_system == \"Windows\""}
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
devenv = ["black", "check-manifest", "flake8", "pyroma", "pytest (>=4.3)", "pytest-cov", "pytest-mock (>=3.3)", "zest.releaser"]
|
||||||
|
|
||||||
|
[metadata]
|
||||||
|
lock-version = "2.0"
|
||||||
|
python-versions = "^3.10"
|
||||||
|
content-hash = "8bd35d6d45560fb85b81b2498dd0e3cadfd2cb55d341505bf409262271e5461b"
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "morny-coeur-python"
|
name = "morny-coeur-python"
|
||||||
version = "0.1+coeur0.7.2.1"
|
version = "0.1.1+coeur0.7.2.1"
|
||||||
description = "A Coeur-Morny-Cono rewrite by python3"
|
description = "A Coeur-Morny-Cono rewrite by python3"
|
||||||
authors = ["Eyre_S <sukazyo@outlook.com>"]
|
authors = ["Eyre_S <sukazyo@outlook.com>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
132
start.py
132
start.py
@ -1,132 +0,0 @@
|
|||||||
import os
|
|
||||||
import sys
|
|
||||||
import threading
|
|
||||||
from define import Coeur_Def
|
|
||||||
from logger.logger import *
|
|
||||||
from morny.morny_hello import morny_hello_text
|
|
||||||
|
|
||||||
|
|
||||||
thread_morny_init = "morny-init"
|
|
||||||
prop_name_token_tg_key = "TELEGRAM_BOT_API_TOKEN"
|
|
||||||
prop_name_token_morny_key = "MORNY_TG_TOKEN"
|
|
||||||
|
|
||||||
##
|
|
||||||
##
|
|
||||||
## 启动参数的声明
|
|
||||||
|
|
||||||
versionEchoMode:bool = False
|
|
||||||
welcomeEchoMode:bool = False
|
|
||||||
showWelcome:bool = True
|
|
||||||
key:str = None
|
|
||||||
username:str = None;
|
|
||||||
outdatedBlock:bool = False
|
|
||||||
master:int = 793274677
|
|
||||||
trustedReadersOfDinner:set = set()
|
|
||||||
trustedChat:int = -1001541451710
|
|
||||||
autoCmdList:bool = False
|
|
||||||
autoCmdRemove:bool = False
|
|
||||||
api:str = None
|
|
||||||
api4File:str = None
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
##
|
|
||||||
## 从命令行与环境变量读取启动参数值
|
|
||||||
|
|
||||||
i = 1;
|
|
||||||
while (i < len(sys.argv)) :
|
|
||||||
|
|
||||||
if (sys.argv[i].startswith("-")):
|
|
||||||
|
|
||||||
match sys.argv[i] :
|
|
||||||
case "--outdated-block" | "-ob" :
|
|
||||||
outdatedBlock = True
|
|
||||||
i+=1;continue
|
|
||||||
case "--no-hello" | "-hf" | "--quiet" | "-q" :
|
|
||||||
showWelcome = False
|
|
||||||
i+=1;continue
|
|
||||||
case "--only-hello" | "-ho" | "-o" | "-hi" :
|
|
||||||
welcomeEchoMode = True
|
|
||||||
i+=1;continue
|
|
||||||
case "--version" | "-v" :
|
|
||||||
versionEchoMode = True
|
|
||||||
i+=1;continue
|
|
||||||
case "--token" | "-t" :
|
|
||||||
i+=1; key = sys.argv[i]
|
|
||||||
i+=1;continue
|
|
||||||
case "--username" | "-u" :
|
|
||||||
i+=1; username = sys.argv[i]
|
|
||||||
i+=1;continue
|
|
||||||
case "--master" | "-mm" :
|
|
||||||
i+=1; master = int(sys.argv[i])
|
|
||||||
i+=1;continue
|
|
||||||
case "--trusted-chat" | "-trs" :
|
|
||||||
i+=1; trustedChat = int(sys.argv[i])
|
|
||||||
i+=1;continue
|
|
||||||
case "--trusted-reader-dinner" | "-trsd" :
|
|
||||||
i+=1; trustedReadersOfDinner.add(int(sys.argv[i]))
|
|
||||||
i+=1;continue
|
|
||||||
case "--auto-cmd" | "-cmd" | "-c" :
|
|
||||||
autoCmdList = True
|
|
||||||
autoCmdRemove = True
|
|
||||||
i+=1;continue
|
|
||||||
case "--auto-cmd-list" | "-ca" :
|
|
||||||
autoCmdList = True
|
|
||||||
i+=1;continue
|
|
||||||
case "--auto-cmd-remove" | "-cr" :
|
|
||||||
autoCmdRemove = True
|
|
||||||
i+=1;continue
|
|
||||||
case "--api" | "-a" :
|
|
||||||
i+=1; api = sys.argv[i]
|
|
||||||
i+=1;continue
|
|
||||||
case "--api-files" | "files-api" | "-af" :
|
|
||||||
i+=1; api4File = sys.argv[i]
|
|
||||||
i+=1;continue
|
|
||||||
|
|
||||||
warn(f"Can't understand arg to some meaning :\n {sys.argv[i]}")
|
|
||||||
i+=1
|
|
||||||
|
|
||||||
|
|
||||||
propToken:str = None
|
|
||||||
'''从系统环境变量设置的 bot token 值'''
|
|
||||||
propTokenKey:str = None
|
|
||||||
'''表明 bot token 值的来源是哪个系统环境变量'''
|
|
||||||
|
|
||||||
for iKey in [prop_name_token_tg_key, prop_name_token_morny_key] :
|
|
||||||
if (os.getenv(iKey) != None) :
|
|
||||||
propToken = os.getenv(iKey)
|
|
||||||
propTokenKey = iKey
|
|
||||||
|
|
||||||
##
|
|
||||||
##
|
|
||||||
## 启动参数的检查和处理
|
|
||||||
|
|
||||||
if versionEchoMode :
|
|
||||||
info(f"""Morny Cono Version
|
|
||||||
- version :
|
|
||||||
{Coeur_Def.VERSION} {Coeur_Def.CODE.upper()}
|
|
||||||
- md5hash :
|
|
||||||
<unavailable_in_python_implementation>
|
|
||||||
- rw.time :
|
|
||||||
{Coeur_Def.TIMETAG} [UTC+8]"""
|
|
||||||
); exit()
|
|
||||||
|
|
||||||
if showWelcome : info(morny_hello_text())
|
|
||||||
if welcomeEchoMode : exit()
|
|
||||||
|
|
||||||
info(f"""start.py Executed >>>
|
|
||||||
- version {Coeur_Def.VERSION} [{Coeur_Def.TIMETAG}]
|
|
||||||
- Morny {Coeur_Def.CODE.upper()}""")
|
|
||||||
|
|
||||||
##
|
|
||||||
##
|
|
||||||
## Coeur 参数检查以及正式呼叫主程序
|
|
||||||
|
|
||||||
if (propToken != None) :
|
|
||||||
key = propToken
|
|
||||||
info(f"Parameter <token> set by EnvVar ${propTokenKey}")
|
|
||||||
if (key == None) :
|
|
||||||
info("Parameter required has no value:\n --token.")
|
|
||||||
exit()
|
|
||||||
threading.current_thread().name = thread_morny_init
|
|
||||||
#todo call coeur main
|
|
Loading…
Reference in New Issue
Block a user