Skip to content

Commit

Permalink
V2.2, Date support
Browse files Browse the repository at this point in the history
  • Loading branch information
hexadecimal233 committed Apr 7, 2022
1 parent 66b926c commit c26df86
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

``advancedMode`` 是否高级开启模式.

##### ``advanced`` 用来判断条件.
### ``advanced`` 用来判断条件

* ``criteria`` 条件,有 ``time``, ``date``, ``fans``

Expand All @@ -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``就会启用随机简介, (数组)其余参数可省略.

Expand Down
15 changes: 11 additions & 4 deletions bili-signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
19 changes: 16 additions & 3 deletions config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -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": "现在是四月十号之后~"
}
}
}
}
},
Expand Down

0 comments on commit c26df86

Please sign in to comment.