Skip to content

Commit

Permalink
put auto issued notices into NotRemind (#789)
Browse files Browse the repository at this point in the history
* support auto issue

* move init autoissue

* add plugin.bugit in config

* move config check into CheckerEventHandler

* change config name to event.notice
  • Loading branch information
ZhaoYangyang0403 authored Sep 26, 2023
1 parent 4ca429b commit e4afff7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions lyrebird/checker/event.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
from lyrebird import application
from .. import checker

Expand All @@ -21,10 +22,21 @@ def issue(self, title, message):
"title": title,
"message": message
}
self.check_notice(notice)
application.server['event'].publish('notice', notice)

def publish(self, channel, message, *args, **kwargs):
if channel == 'notice':
self.check_notice(message)
application.server['event'].publish(channel, message, *args, **kwargs)

def check_notice(self, notice):
stack = inspect.stack()
script_path = stack[2].filename
script_name = script_path[script_path.rfind('/') + 1:]
if script_name in application.config.get('event.notice.autoissue.checker', []):
notice['title'] = f"【Extension】{notice.get('title')}"
notice['alert'] = False

@staticmethod
def register(func_info):
Expand Down
3 changes: 2 additions & 1 deletion lyrebird/notice_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def new_notice(self, msg):
"""
unique_key = msg.get('title')
alert = msg.get('alert', True)
if self.notice_hashmap.get(unique_key):
self.notice_hashmap[unique_key]['noticeList'].append(msg)
if self.notice_hashmap[unique_key].get('alert'):
Expand All @@ -86,7 +87,7 @@ def new_notice(self, msg):
self.notice_hashmap.update(
{
unique_key: {
'alert': True,
'alert': alert,
'noticeList': [msg]
}
}
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (2, 19, 2)
IVERSION = (2, 20, 0)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit e4afff7

Please sign in to comment.