1
0
mirror of https://github.com/Eyre-S/Coeur-Morny-Cono-python.git synced 2024-09-27 18:56:20 +08:00

简单完成 messiva 功能实现,完成 ServerMain(start.py) 重写

- 附带添加 define 声明
  - 由于系统差异未能实现编译时间戳与可执行件 md5 校验值的功能
- 附带添加 MornyHello 重写
This commit is contained in:
A.C.Sukazyo Eyre 2022-09-26 16:08:18 +08:00
parent 29fed96a3b
commit b9b06596b6
Signed by: Eyre_S
GPG Key ID: EFB47D98FE082FAD
5 changed files with 210 additions and 0 deletions

6
define.py Normal file
View File

@ -0,0 +1,6 @@
class Coeur_Def :
VERSION = "0.7.2.1-py0.1"
CODE = "fuzhou"
TIMETAG = "2209261500"

View File

@ -2,6 +2,9 @@ from datetime import datetime
import threading
from .log import *
def output (message:Log) :
print(format_message(message))
def format_message (log:Log) -> str :
origins = log.message.split("\n")

View File

@ -0,0 +1,10 @@
from logger.log import Log, LogLevels
from logger.log_appender import output
def trace (msg:str) : output(Log(msg, LogLevels.trace))
def debug (msg:str) : output(Log(msg, LogLevels.debug))
def info (msg:str) : output(Log(msg, LogLevels.info))
def warn(msg:str) : output(Log(msg, LogLevels.warn))
def error (msg:str) : output(Log(msg, LogLevels.error))
def fatal (msg:str) : output(Log(msg, LogLevels.fatal))

59
morny/morny_hello.py Normal file
View File

@ -0,0 +1,59 @@
def morny_hello_text () -> str:
return r"""ttt///t/////fucj(\tvnxtf{< .' .. .:i` . . ^!`l|-^i+,!_[:1/|{i?//\//jf\\\///\\\\//\\\//////\\/\\\\\\\\\\\\\\//\\\\/\\\\/\\//\\\///\\\\\\\\\\\\\\\\\\\\fnncvvU0O00QCx!!". .. `
tt//////////\jzjrucnjt/?{j,,"' . .' .. .":. .;{: ' "`.,1(<."i?)\(-}\\\(((\\/\\\\\\\\\\\\\\\\///\//////\\\\\\\\\\\\\\\\\\\\\\\|\\\\\\///\\///\\\\\\\\|\\\\\\|\\\\\\\\tvXvuXcxn/[<!l~<` `I`.
tt//////t////\//|rvx//\(((-;,''" ",.,II..' `. . ^"' . .` .. .. .:: ```!],";";;^ "!?)/_ :li~)1[;<li<(\1(1;+||\||\\\\\\\\\||\\\||\\\\\///\\\\\\\\\\\\\\\\\\\\\\\\\\\||\\\\\\\\//\\\\\\\\\\\\\\\\\/\\||\\\\\\\\\\\\||||\\//t{}[!>Il)({_:.. ."` .,
//////////////////\////|)/([}-_<+[]>.^^""[<'`^` .''""`'.`'`"i! ^!>l:' :<" !!.IiI`+l^^`i>_<`??)1;^{\\\\\{|({({|/\]I)\\()\(]}|\\||\|||\/\\\\\\|||\\\\\\\\//\\\\/\\\\||\\\\\\\\//\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//\\\\\\\\\\\\////\\\\\\\\\//|{{?{|)[[-;
ttt/tt//////////////////{)(\t(/tt/1~I}{-1\_^])1_+[{|(?"<1~>>+!+[}11)}[(1}]};^1\|~_1}{I:-1(I+)(|))|\\/////////\\////\\\/////\\\\\\\\\\\\\\/\//\\///\//||\////|)(//\\///){\/\(11|///({)//({[1\\\\\\\\\\|\/\\\/\//////////\\\\\\\\\//\\\\\///////\|\\\\//////\\///\
tttt/////////////\///////\||///////t//|(|)|}|\/(\\(//(l_{{<i!l}}})(()\/\///{{|||\\|\\((\\\\\\\\\\\////\\\\\//\\/\////\///\\\\\\\\\//\\\\/\|}[{|1?{|[i:,,;i<i,,,I~}}<<l^":I,`.':-<l!~l~i:!;,l)\\/\//\/\\\/////\\\//\\////\\\\\\\\//\\\/\\///\\/\\\\\\\\\\\\\\\\//
//t//////////////\///////////////////////\//////////////////\/\/////\\\\\\\//\\|||\\/\\\\\\\\\\\\\/\\\\\\\\\\//\\/////////\\\\|))([+)}!<~"^,^.`' .^."~, :` '" `_>. ... ">+<^'I!: ^<(\\1}1//\\\//////////\\///\/\///\\\\\\//\\//\\\\\\\\\\\\\\///\(/\{
t////////////////////////////////////////////////////////\/\\///////\\\\\\\\\\\\\\\/\\\\\\||\|\\\\\|\\\\/\\|\\\\\\////((|///}!:,":,^`. .;' ' '^..':. ^!;. .^^ '^^`. '' ...I[{!>:^;_i:'~\ttt/////tt//\\////////////\\\\/\\\\\\/\\\\/\\\\\)}-+[+I??i
ttt////////////////////////////////////////////////////////\\//\//\\/\\\\\\\\\\//\\\\\\||\\\/\//\\\\\\\\\/\|\\\////\1;``^;<>+!">__+I `' .. "'. .;" ;;. .:^ ``,,;'` .;]I ,-_-|\////t////t///////\/\\\\//\\\\\\//\\\///////-II<!l_; I
/////////////////////////////////////////////////\\/\\\\\////\\//\\/////\///////////tt//\\/\////\/////t/\//\\///\]{\l,`'+< ,i ^i" . .`"l" . .`;?-' .` `>1ttt///tttt/////////\/\/////\\\\////t|+<}?!-]l<{[[1-+]
t//////////////////////////////////////\/////////\////////////////\//////\//tttttttttt//////////////////////////)_)t)|}1f/{<.^,^:~: . .. '''^:-|/> '-/}-_?\/)-{?(//\(\tt////\///\\\\\\\///t1.;); .l~` '"
///////////////////////////////////////////tt/t(|tt//]+{t\{][|////\//////////ttttt///t//t/////////////\//////|//{[|f}!l<!!I, `' ,!!i+- .`:l;IIll>>~++~<<<!:`. '' '^-l `.,l:.`{{[_:]/1l;>\//]l~?])tt//\\\\\/\\///\\|?<_}["^!;I^;]:. .
////////////////////////////////tttt/|{[1)]~!!+>!<_(/|[-<"i!l,]tt//ttt/t////ttt//t///ttttttt////////t//t//ttt){+. :?^ '. l_-!+l;;;|!!>~~il!lllllllllll!!lI:`'. .' :I;]_}>,?tf:.+fft)l+1//\~`'I-(//\/t/|/(-1[)/?>>II:' '.`';-'`
/////////////////////////t//()\1_<>il^'''' ,!>;.,.'{tti `~tf(`'-(|fffftttttttttt/tttttttttttt///tttft//(t|]?-+!^ ."`. `. ;!I,. .?{il-\_!~<>>!lII;IllIIIIIllllllllllI;;:,:,' '"^`(f{+{>' .<{t(I!}/||t> ^(//}>;:1\]: "[:"` ^<: . II.'..
///////////////ttt//tt((-!+}"'^. I, ,?<:' ,:;!>~',!_~{}-1]`^!}_+\ttttttt/tttttttfff/tt\(||]-?+;,:"l" '..'.. ?]l:" -(lI;,~?~!IIIlllI:IIlI;IIIIlllllllIIIIIllII!; . . '^^;~), "~!}\/t//\\/_. '</||1?-)/\\)+_1>". '_i !i'''
tt//t///ttt///(]<>l>][l"'.`,. ^.^. ii ;; ~>>>. .i~I'^^<}), .;|tfftttttttttttf\]}t-!,,I` .^ '. !: . .",I;. ^,I<)/-l:;llllllI;lIll;;IIIIlllIllIlIIlIllI;><. ' .;}". '.:+](ft\}(t/t{;<\{l^>}!^l\/{>1/t(lI:I!+<<". ':"
t//tttt|?+!I!:' '` .`. ...... `^ "<^.;`^"'`,!".,^^^.,?)!. [f/+>(/tttft\tff|+^,!' '^: >[,++:`' .I^ . _?!:^. ;~{/<II:IllIlllI;l;IlI;;IIIIIIlIIIIIIllIlllI+- "+;,...<\;^_(/~}t/(+ ^(/?.:|)il)\>?//)! __::. ':. '.
t/\}[{]",il'`!-<-]:`'^` .. '' .^+:'. .^'"i:`^. ';`:<_|>'.?/t/!"<)ffftf)]]!'II.,l ^' ''. '";" .' `Il, ;]>]j_;lI;ll;!!llIII>~IIIIII;:<iIlIIlII;llllll;(> ;,~.',.<:`, 'I_|\; .i|/]^ ?(}\/////\i' '' ....'^
tf1<}i `^. `I` .I?"'. . . ^' .^' .'` .". >}_.I|t{_(tf({~,~(); ')t};.><,. .. . .. . . .]}^{j1IlllIlI!1IlllII?{IIIIIlI;[1!I;IIllIIlIIllI<x" '.!+~!,``...:. 'l]?l"i{/\><]_;+/t\(|\/1,' "` ...
)+::((:^' ll .,` . . ..'. ' :+'`{tj{,l: ^;"..;!"^.I?' '~; .` .'. . `1+ [x?-:lIlll!]r-IllI~~{~I>lllll[i\--+;;I~IIIII!l;x] "I"-<<_> >i.' l{}:itf/}[/\)(\}))|(:^^..'. `".
>.._f|i.:l,;^^''__. .^' `' "+<!~)?,,[>,`]1i`!1_. ^l: .". .` '1I +JIt!IIlll;]\<vlIlI(;I\i+<iII>) >1}c(_i(!IllI_l;(f. ,_";~~+^ .. .;-i '+([i+: !//1](||/\(?:^..^^
i'"}_,.` ''^... '. `. ^<`_> .. +x??_~]:[|!,.ll` . {+ ;Y[^|,>~IlIIf\ {/;I!\ [[-'<+l-{ _??]f\n]lllI[!;1v` `+"]-}]~" ..'`l, ''i-` l+?\\\/t{!)t[:' .^^
;,:: :,^..;:. . i+..;^ `_<!,!~II,`. '' . "t..\n^!]!i]<II!n> ]]<-?l``-]' I>]?+<l~<!._n_IllI1+i}J: ...l!,'`' `. . .~>. ^-|\\_I?]{t/?` ....
^(\]I^~?;."!" . .. . ^<^ :( >t) _[il>|+:(U<1nYQ0Xx\> . .~xcXXYzx(n?IllI}">xCI .:1]_-" . .^. `}>!}((1-^,+?" ..
1+,~I.<! .`' .. `x"(+1 >(l<?_1}Cj!f\?l"' '"I~]|_;Ill{ vQ" ':,~_' .. .. .`^[(`,?\||\+ '," .
}<. `^]!.;lI>' . ... ~|r:;`.+I?\};+t) "".-?;lI>(;]xn. '_>]!+. '^'`l:11l[|((+?: .
[-`.':;..""' lv|. .:_(;I!u> ^,",^. .;?I]?IlI}n[</( "+'.. .I]; ',;!\/\|~I}" '";'.
.,><I>^ ')(I' `tlII>x1" <}1{)l "~+ |[II;\[:~zl .i;. .... `"i\\}]..!' ^....
-" ` ' . ":` .|+<<;!\U)>^ '^`' ^"I?)c-;<if]>j/ <1I~;` .!}\(: .;"`'
' 'l, .' ~[><+;!f()nn|]!:' ..^:!+1fcjx}}v!_)})>|n` ~^ ^;"'` .<+I<)/||\i'"<"'^ `.
II ^}_'+_!fI?_/-jJjUr\\ucJJz\|J>}?-j{]^ni<z; : `' .-+~->" .;](),.;-<`' .^ .^'
+[" +]{.`i;I</-jmvxjj)<^ !0~l-?+` : '" '` .' l\)-++{f\" ',^^^ .^ ,!` ''
.>; ::."!??l.^Ywj}<, (n, ,~_:` .,, ` `` ' '... ^+-l,]}]}\j/!. . ` 'I<~`'{tl..^`
'' .,<{[>" i/i" `-[; ,<_[>^i_l,:^_! ',+l.. ^,:,,. ;~>l;^ l> ',;I^???~,'l".. ..
;{?l. !+ .. .<1i '^' "}|{:-+-;?\[)-] ^:l1-:. '' '`, . ';.`~^ '. ..^`.
'i+;]}!,. <))\!<|ji >((_}}?t)}\\v|]?jI!), "lf!l. ... .^ . ".
.+{>` l/z\!,>""I+~_){]<t~-(! .!nt_]]]])1)]]\( ?_' :( . . `:. `; ." ... ..
Ir. ..>vQjut_~~>>>_-<]<-)f":l_v){\/1}}}{t/\0?z~. ^' `-l . . .. .
l\ :_>>i:^+\)_-]!:>-+<?\Uzfjj-/mxt|[??/f)??}/mc1;. . . . ^' .
I1I`l?-}l>l'...`^;1!^ 'l>})l\n\Qt?]?]})1{][[(XC>^ ...
^-+^.i-((?!"`:>l<[<!tc_:;<+>~<]nQY+?????][{\cmO||l . ''..
'|: '^[{~)\_+++))1{uxnvt(t){{[[u0\1|({1()){-?|xfc: ..
.<-, ]-]]]})11)){{{{}{{)|{}}{1{111{11{{}}]_!"x\]Xf
,]<\}][[[[[[[[[[[[[[[]][[[[[[[[][[[[[[]?-+!YC{z} .`
"_[}?]][[[[[[[[[[[[[[[[[[][[[[[[[[[[[[[[[]vn\?. ^
^. ;{_(_??][[[[[[[[[[[[[[[[[|[[[[[[[[[[[[[[[[v_(]^
.' '. :t>/?[[[[[[[[[[[[[[[[[[[]t\][[[[[[[[[[][]?u;()_ .. .'. . .
`. .` :)!j_]][[[]]]]][[[[[[[[[[}j(/{[[[[[][[}1{~n!)ft . .. .. . .. .
". ..' .` . "' .^":;~ti{\1]][]]]??]]]]][]]??[){[}[[[[?+}]<I"]({~c' .,",. .. ', .'`I' ^l.
. .. .'. ..'.... '.;,.'.":`,_: '` . '"^. '<:,'. 'l:`'. . ';"'. .i~I:;,,`.^!{[?[[[[[[[[[[[[[[]?]]]])t11])I;:. '^c^ .. '. . .' .^ .."?, '`
' '^. `. . I;. . `^ '... ...``'. ,">!^':``^``,`;I.!<>?>:??i:;-;,<_..^,Ii: 'l,i+```' ..'!; ''. ?~.'<+ .li!:,1?}[[[[[[[[[[[[[[[[[[[[)1}]t[:, "O" . .' . ^!' . ". i+' .
^. . .':`'`~/1,-<-~^'^'^^,`.."i_>^. `1t]!,^I]l^;`,I::_?]?[!:;`.`"'`l!l<1f{~>;]\1(]I>~l!l[<,,;`lI,~},^>!>l<l[-' I-+:i_!ll::l"`>'...'": 'x' ]l>i .:I1[~]]]]}}}}}[[}}[}}}}}[[]]]??1}}[}~;:>vx. :;..:??,.' ^` I;>.";:"^' .. ^'.^"" ' .!},' .
~!;:!".":i"^_/|]^li(\1;;it{' .[\fft+<}(/{}/)|f||<tj\/1//jj[<<~])11?''.`;\)l!(ff~!\j1-|\t\f\//||>'.^{/[)?!:(?+-,I+fjtil"'"+fj{i:',!!;!!^:.`r. r; !l'"i1?!i>~+_?][[[?-???]][[]?-+-]??+~<_{[_l?> ''^l;l`-}<`^.i>+l ``;I":+?!~-l ,>>l.'.;. ':!!(/!":,I
/t<I^^!{{-;[[-~|1\jj\?(/)f{~~+}}//t(?(ft}{tf]j1>1ffft+{jff/ttff)];)?1(/tt\/t/tfttttfftf/1\|t\|/?<_]_]{<_]/f({fffjttf/[i>1//|tft|" :<~:+}, ]>if" .:-~ >) ^`^l)f(_<??)\}}(t|}>{/\}-+1\()t-{j/]!:^'l<]\)+ ."_?I_{
ffft)|)(t[_-{tjjrjrj/{(||}(rjj\1)I<\((ffj/rjffttjffftrjfffrtfff/f[1jjffffftt//)}tttff/ttt[<{rj}tf1?<:~{/j)>)fttf|?)tfffftt1_;+tf1-1|~i1, >;:} '1_ ;( .. .. `:"_1{}tjtvj)vjr/|jfff/<(tf)+1/)1j)~~-[j[l|[(/\j{:-]]([}\t"""

132
start.py
View File

@ -0,0 +1,132 @@
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