|
@@ -0,0 +1,55 @@
|
|
|
+import tomlkit
|
|
|
+
|
|
|
+
|
|
|
+# ----- Toml Methods -----
|
|
|
+def GetTomlDoc(tomlName:str):
|
|
|
+ try:
|
|
|
+ with open(tomlName, "rb") as t:
|
|
|
+ doc = tomlkit.load(t)
|
|
|
+
|
|
|
+ if doc == {}:
|
|
|
+ input("error 0: could not found correct config file")
|
|
|
+ exit()
|
|
|
+
|
|
|
+ return doc
|
|
|
+
|
|
|
+ except FileNotFoundError:
|
|
|
+ input("error 0: could not found correct config file")
|
|
|
+ # sec_respond?
|
|
|
+ exit()
|
|
|
+
|
|
|
+def MatchTomlKey(tomlName:str, key:str, table:str="str") -> str:
|
|
|
+ doc = GetTomlDoc(tomlName)
|
|
|
+
|
|
|
+ if table == "str":
|
|
|
+ return str(doc.item(key))
|
|
|
+
|
|
|
+ elif table == "list":
|
|
|
+ return list(doc.item(key))
|
|
|
+
|
|
|
+ elif table != "table":
|
|
|
+ d = doc.unwrap()
|
|
|
+ return str(d[table][key])
|
|
|
+
|
|
|
+
|
|
|
+reg = MatchTomlKey("config.toml", "registered", "list")
|
|
|
+weekly = MatchTomlKey("config.toml", "weekly", "str").split("\r\n")
|
|
|
+
|
|
|
+weekly = weekly[2:-1]
|
|
|
+bouns = 0
|
|
|
+window = []
|
|
|
+
|
|
|
+for name in weekly:
|
|
|
+ window = name.split(" ")
|
|
|
+
|
|
|
+ try:
|
|
|
+ if int(window[2]) >= 3:
|
|
|
+ bouns = bouns + 1
|
|
|
+
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|
|
|
+ reg.remove(window[1])
|
|
|
+
|
|
|
+print("未打卡名单(%s): " %(len(reg)), reg)
|
|
|
+print("红包数量: ", bouns)
|