根据PR意见进行修改 使用autopep8调整格式
This commit is contained in:
@@ -7,12 +7,12 @@ from robot import Robot
|
||||
class ReportReminder:
|
||||
|
||||
@staticmethod
|
||||
def remind(robot) -> None:
|
||||
def remind(robot: Robot) -> None:
|
||||
|
||||
receivers = robot.config.REPORT_REMINDERS
|
||||
if not receivers:
|
||||
receivers = ["filehelper"]
|
||||
#日报周报月报提醒
|
||||
# 日报周报月报提醒
|
||||
for receiver in receivers:
|
||||
today = datetime.datetime.now().date()
|
||||
# 如果是非工作日
|
||||
@@ -24,7 +24,7 @@ class ReportReminder:
|
||||
# 如果是本周最后一个工作日
|
||||
if ReportReminder.last_work_day_of_week(today) == today:
|
||||
robot.sendTextMsg("该发周报啦", receiver)
|
||||
# 如果本日是本月最后一整周的最后一个一个工作日:
|
||||
# 如果本日是本月最后一整周的最后一个工作日:
|
||||
if ReportReminder.last_work_friday_of_month(today) == today:
|
||||
robot.sendTextMsg("该发月报啦", receiver)
|
||||
|
||||
@@ -34,14 +34,15 @@ class ReportReminder:
|
||||
days_in_month = calendar.monthrange(d.year, d.month)[1]
|
||||
weekday = calendar.weekday(d.year, d.month, days_in_month)
|
||||
if weekday == 4:
|
||||
last_friday_of_month = datetime.date(d.year, d.month, days_in_month)
|
||||
last_friday_of_month = datetime.date(
|
||||
d.year, d.month, days_in_month)
|
||||
else:
|
||||
if weekday >= 5:
|
||||
last_friday_of_month = datetime.date(d.year, d.month, days_in_month) - datetime.timedelta(
|
||||
days=(weekday - 4))
|
||||
last_friday_of_month = datetime.date(d.year, d.month, days_in_month) - \
|
||||
datetime.timedelta(days=(weekday - 4))
|
||||
else:
|
||||
last_friday_of_month = datetime.date(d.year, d.month, days_in_month) - datetime.timedelta(
|
||||
days=(weekday + 3))
|
||||
last_friday_of_month = datetime.date(d.year, d.month, days_in_month) - \
|
||||
datetime.timedelta(days=(weekday + 3))
|
||||
while not is_workday(last_friday_of_month):
|
||||
last_friday_of_month = last_friday_of_month - datetime.timedelta(days=1)
|
||||
return last_friday_of_month
|
||||
@@ -50,8 +51,10 @@ class ReportReminder:
|
||||
@staticmethod
|
||||
def last_work_day_of_week(d: datetime.date) -> datetime.date:
|
||||
weekday = calendar.weekday(d.year, d.month, d.day)
|
||||
last_work_day_of_week = datetime.date(d.year, d.month, d.day) + datetime.timedelta(days=(6 - weekday))
|
||||
last_work_day_of_week = datetime.date(
|
||||
d.year, d.month, d.day) + datetime.timedelta(days=(6 - weekday))
|
||||
|
||||
while not is_workday(last_work_day_of_week):
|
||||
last_work_day_of_week = last_work_day_of_week - datetime.timedelta(days=1)
|
||||
last_work_day_of_week = last_work_day_of_week - \
|
||||
datetime.timedelta(days=1)
|
||||
return last_work_day_of_week
|
||||
3
main.py
3
main.py
@@ -6,7 +6,7 @@ import signal
|
||||
from wcferry import Wcf
|
||||
|
||||
from configuration import Config
|
||||
from report_reminder import ReportReminder
|
||||
from func_report_reminder import ReportReminder
|
||||
from robot import Robot
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ def weather_report(robot: Robot) -> None:
|
||||
robot.sendTextMsg(report, r)
|
||||
# robot.sendTextMsg(report, r, "nofity@all") # 发送消息并@所有人
|
||||
|
||||
|
||||
def main():
|
||||
config = Config()
|
||||
wcf = Wcf(debug=True)
|
||||
|
||||
Reference in New Issue
Block a user