NandHyf před 6 měsíci
revize
2cd51057f3
2 změnil soubory, kde provedl 96 přidání a 0 odebrání
  1. 55 0
      ByeFat.py
  2. 41 0
      config.toml

+ 55 - 0
ByeFat.py

@@ -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)

+ 41 - 0
config.toml

@@ -0,0 +1,41 @@
+registered = [
+"Daniel", 
+"Kai", 
+"王硕", 
+"MeoK", 
+"张宇", 
+"高大为", 
+"于志鹏", 
+"肥仔",
+"Alex_志勋",
+"杨子璇",
+"Nand.H",
+"何维溢",
+"何先均",
+"🌊",
+"魏宇昕",
+"Michael",
+"姚瑶",
+"yue@灵雀云"
+]
+
+
+weekly = '''
+#接龙
+
+1. 肥仔 3
+2. Kai 3
+3. 姚瑶 请假
+4. Alex_志勋 5
+5. 王硕 7
+6. 于志鹏 3
+7. 何维溢 3
+8. Nand.H 3
+9. 🌊 3
+10. 魏宇昕 3
+11. MeoK 3
+12. Daniel 3
+13. 张宇 2
+14. 何先均 6
+15. Michael 3
+'''