浏览代码

添加法定节假日插件,设置6月后无需打卡

iaun 5 年之前
父节点
当前提交
2871799309
共有 4 个文件被更改,包括 9 次插入6 次删除
  1. 1 1
      README.md
  2. 6 4
      config.py
  3. 0 1
      kaoqin.py
  4. 2 0
      requirements.txt

+ 1 - 1
README.md

@@ -3,7 +3,7 @@
 
 2. 安装requests模块
 ```
-pip install requests
+pip install -r requirements.txt
 ```
 
 3. 复制一份sample文件到para.py

+ 6 - 4
config.py

@@ -1,20 +1,22 @@
 import datetime
 
+from chinese_calendar import is_holiday
+
 ## 考勤范围:在指定时间区间内,随机时间进行考勤
 # 考勤范围开始,格式 [小时, 分钟]
 START_TIME = [8, 0]
 
 # 考勤范围结束,格式 [小时, 分钟]
-END_TIME = [9, 0]
+END_TIME = [10, 0]
 
 
 # 自定义规则(此处设置周六周日不打卡,1月后不打卡)
 def check_rule():
-    t = datetime.datetime.now()
-    if t.weekday() == 5 or t.weekday() == 6: # 周六日无需打卡
+    t = datetime.date.today()
+    if t.weekday() == 5 or t.weekday() == 6 or is_holiday(t): # 周六日无需打卡
         return False
     
-    if t.month != 1: # 1月后假期无需打卡
+    if t.month > 6: # 6月后无需打卡
         return False
     
     return True

+ 0 - 1
kaoqin.py

@@ -1,5 +1,4 @@
 import requests
-import urllib.parse
 import json
 import random
 import time

+ 2 - 0
requirements.txt

@@ -0,0 +1,2 @@
+chinesecalendar
+requests