diff --git a/README.md b/README.md index a195f66..71b3e92 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ ``advancedMode`` 是否高级开启模式. -##### ``advanced`` 用来判断条件. +### ``advanced`` 用来判断条件 * ``criteria`` 条件,有 ``time``, ``date``, ``fans`` @@ -38,14 +38,18 @@ * ``value`` 与结果比较的值. 只支持整数. (RPN type value) * 对于time: - * ``time`` 时间. (HH:MM) + * ``time`` 时间. (%H:%M) * ``type`` 当结果>=,>,<=,<,=比较的值时,根据条件更改简介. -* ``ifTrue`` 返回真时的简介. + * 对于date: + * ``date`` 日期. (%Y-%m-%d) + * ``type`` 当结果>=,>,<=,<,=比较的值时,根据条件更改简介. + +* ``ifTrue`` 返回真时的简介. * ``ifFalse`` 返回假时的简介. -* ###### 简介格式: +* ### 简介格式 * 如果上两个参数里有 ``tw`` 则进行套娃, 其中是 ``advanced``, 有``data``就会启用随机简介, (数组)其余参数可省略. diff --git a/bili-signature.py b/bili-signature.py index e4184c6..092b73d 100644 --- a/bili-signature.py +++ b/bili-signature.py @@ -9,12 +9,12 @@ from sys import exit from time import sleep -VERSION = '2.0' +VERSION = '2.2' class BilibiliApi(object): #调试模式 debug = False - debugFans = 2003 + debugFans = 1994 #上一粉丝数 __fans = 0 @@ -143,14 +143,21 @@ def parseCriteria(self, cfg, fans): compared = datetime.datetime.strptime(timeCfg['time'],'%H:%M') nowDaytime = datetime.datetime.strptime(datetime.datetime.now().strftime('%H:%M'),'%H:%M') cond = compare(timeCfg['type'], nowDaytime, compared) - return cond + time_ = cond else: time_ = 1 + if 'date' in cfg: + timeCfg = cfg['date'] + compared = datetime.datetime.strptime(timeCfg['date'],'%Y-%m-%d') + nowDate = datetime.datetime.strptime(datetime.datetime.now().strftime('%Y-%m-%d'),'%Y-%m-%d') + cond = compare(timeCfg['type'], nowDate, compared) + date_ = cond + else: date_ = 1 if 'fans' in cfg: fansCfg = cfg['fans'] fans_ = self.parseFansType(fansCfg['RPN'], fansCfg['type'], fansCfg['value'], fans) else: fans_ = 1 - return (fans_ and time_) + return (fans_ and time_ and date_) #解析粉丝 def parseFansType(self, RPN, criteria, value, fans): diff --git a/config.json.template b/config.json.template index 206217e..0828b7c 100644 --- a/config.json.template +++ b/config.json.template @@ -62,9 +62,22 @@ } }, "ifFalse": { - "formatted": false, - "text": "超过1500粉了!离2000粉还有%d个 qwq", - "RPN": "2000 %d -" + "tw": { + "criteria": { + "date": { + "date": "2022-4-10", + "type": "<" + } + }, + "ifTrue": { + "formatted": true, + "text": "现在是四月十号之前~" + }, + "ifFalse": { + "formatted": true, + "text": "现在是四月十号之后~" + } + } } } },