def readPushList(self) -> tuple: data = data_read(self.puth_method + '_' + PushList_config_name,'config') if data[0] != False: self.clear() for PushUnit in data[2]['PushUnits']: self.addPushunit(PushUnit) for PushToAttrs in data[2]['PushToAttrList']: if PushToAttrs['pushTo'] not in self.__push_list[PushToAttrs['message_type']]: continue self.__push_list[PushToAttrs['message_type']][PushToAttrs['pushTo']]['Pushunitattr'] = PushToAttrs['Pushunitattr'].copy() return (True,data[1]) return data
# -*- coding: UTF-8 -*- from helper import data_save, data_read, getlogger import os import traceback import re logger = getlogger(__name__) config_filename = 'permission.json' allow_msg_type = ('private', 'group') permissionList = {'private': {}, 'group': {}} legalPermissionList = {} #权限列表 res = data_read(config_filename) if res[0]: permissionList = res[2] for k1 in permissionList: for k2 in list(permissionList[k1].keys()): permissionList[k1][int(k2)] = permissionList[k1][k2] del permissionList[k1][k2] #权限名称是否合法 def perm_isLegalPerm(perm_group: str, perm_unit: str = None): #权限组与权限名,以字母开头,只能包含字母、数字与下划线 res = re.match(r'(([A-Za-z]{1}[A-Za-z0-9_]*)|\*)', perm_group) if res == None: #权限组验证不通过 return False if perm_unit != None: #以减号开头表示权限拒绝(优先于*号,-*的权限将拒绝所有) res = re.match(r'-?(([A-Za-z]{1}[A-Za-z0-9_]*)|\*)', perm_unit) if res == None: return False
def loadTranstemplate(): global transtemplate res = data_read(transtemplate_filename) if res[0]: transtemplate = res[2] return res
#日志输出 from helper import data_read, data_save, getlogger, TempMemory logger = getlogger(__name__) check_path(os.path.join('templist', 'RSShub', 'twitter')) silent_start = config.RSShub_silent_start #静默启动(启动时不推送更新) base_url = config.RSShub_base proxy = config.RSShub_proxy headers = {'User-Agent': 'CQpy'} proxies = {"http": proxy, "https": proxy} tmemorys = {} tweetuserlist_filename = 'RSShub_tweetuserlist.json' tweetuserlist = {} res = data_read(tweetuserlist_filename) if res[0]: tweetuserlist = res[2] class MyHTMLParser(HTMLParser): def __init__(self): HTMLParser.__init__(self) self.text = "" self.media = [].copy() self.links = [].copy() def handle_starttag(self, tag, attrs): if tag == 'img': self.media.append(dict(attrs)['src']) elif tag == 'a':