def handle_chat(_type, args): if _type == 'chat_msg': uname, msg = args[0] uname = uname.replace('|', '||') return u'|cff0000ff%s|r: %s\n' % (uname, msg) elif _type == 'ob_msg': uname, msg = args[0] uname = uname.replace('|', '||') return u'|c9f5f9fff%s|r: %s\n' % (uname, msg) elif _type == 'speaker_msg': node, uname, msg = args[0] from utils.notify import notify, SPEAKER notify(u'东方符斗祭 - 『文々。新闻』', u'%s: %s' % (uname, msg), level=SPEAKER) node = node and '|G%s' % ServerNames.get(node, node) uname = uname.replace('|', '||') return u'%s|ccc3299ff『文々。新闻』|cff0000ff%s|r: %s\n' % (node, uname, msg) elif _type == 'system_msg': _, msg = args[0] return u'|B|R%s|r\n' % msg else: return None
def on_message(self, node, topic, message): if topic == 'speaker': from settings import ServerNames username, content = message foo = str(random.randint(0x10000000, 0xffffffff)) content = content.replace('||', foo) content = re.sub(r'([\r\n]|\|(c[A-Fa-f0-9]{8}|s[12][A-Fa-f0-9]{8}|[BbIiUuHrRGYW]|LB|DB|![RGOB]))', '', content) content = content.replace(foo, '||') send = u'{}『文々。新闻』{}: {}'.format( ServerNames.get(node, node), username, content, ) groups_on = [int(i) for i in State.dao.get_all_groups_on()] pool.map_async(lambda f: f(), [ partial(State.aya.send_group_message, uin, send) for uin, num in State.aya.get_group_tuples() if num in groups_on ]) elif topic == 'aya_charge': uid, fee = message if fee < 50: return qq = State.dao.get_binding_r(uid) if not uid: return uin = State.aya.qq2uin(qq) if not uin: return State.aya.send_buddy_message(uin, u'此次文文新闻收费 %s 节操。' % int(fee))
def handle_chat(_type, args): if _type == "chat_msg": uname, msg = args[0] uname = uname.replace("|", "||") return u"|cff0000ff%s|r: %s\n" % (uname, msg) elif _type == "ob_msg": uname, msg = args[0] uname = uname.replace("|", "||") return u"|c9f5f9fff%s|r: %s\n" % (uname, msg) elif _type == "speaker_msg": node, uname, msg = args[0] from utils.notify import notify, SPEAKER notify(u"东方符斗祭 - 『文々。新闻』", u"%s: %s" % (uname, msg), level=SPEAKER) node = node and "|G%s" % ServerNames.get(node, node) uname = uname.replace("|", "||") return u"%s|ccc3299ff『文々。新闻』|cff0000ff%s|r: %s\n" % (node, uname, msg) elif _type == "system_msg": _, msg = args[0] return u"|B|R%s|r\n" % msg else: return None
def on_message(self, node, topic, message): if topic == 'speaker': from settings import ServerNames username, content = message foo = str(random.randint(0x10000000, 0xffffffff)) content = content.replace('||', foo) content = re.sub( r'([\r\n]|\|(c[A-Fa-f0-9]{8}|s[12][A-Fa-f0-9]{8}|[BbIiUuHrRGYW]|LB|DB|![RGOB]))', '', content) content = content.replace(foo, '||') send = u'{}『文々。新闻』{}: {}'.format( ServerNames.get(node, node), username, content, ) groups_on = [int(i) for i in State.dao.get_all_groups_on()] pool.map_async(lambda f: f(), [ partial(State.aya.send_group_message, uin, send) for uin, num in State.aya.get_group_tuples() if num in groups_on ]) elif topic == 'aya_charge': uid, fee = message if fee < 50: return qq = State.dao.get_binding_r(uid) if not uid: return uin = State.aya.qq2uin(qq) if not uin: return State.aya.send_buddy_message(uin, u'此次文文新闻收费 %s 节操。' % int(fee))
def on_message(self, node, topic, message): if topic == 'speaker': from settings import ServerNames username, content = message send = u'{}『文々。新闻』{}: {}'.format( ServerNames.get(node, node), username, content, ) groups_on = [int(i) for i in dao.get_all_groups_on()] gids = [ g['gid'] for g in aya.group_list if aya.gcode2groupnum(g['code']) in groups_on ] pool.map_async(lambda f: f(), [ partial(aya.send_group_message, i, send) for i in gids ])
def on_message(self, node, topic, message): if topic == 'speaker': from settings import ServerNames username, content = message send = u'{}『文々。新闻』{}: {}'.format( ServerNames.get(node, node), username, content, ) groups_on = [int(i) for i in dao.get_all_groups_on()] gids = [ g['gid'] for g in aya.group_list if aya.gcode2groupnum(g['code']) in groups_on ] pool.map_async( lambda f: f(), [partial(aya.send_group_message, i, send) for i in gids])
def handle_chat(_type, args): if _type == 'chat_msg': uname, msg = args[0] uname = uname.replace('|', '||') return u'|cff0000ff%s|r: %s\n' % (uname, msg) elif _type == 'ob_msg': uname, msg = args[0] uname = uname.replace('|', '||') return u'|c9f5f9fff%s|r: %s\n' % (uname, msg) elif _type == 'speaker_msg': node, uname, msg = args[0] node = node and '|G%s' % ServerNames.get(node, node) uname = uname.replace('|', '||') return u'%s|ccc3299ff『文々。新闻』|cff0000ff%s|r: %s\n' % (node, uname, msg) elif _type == 'system_msg': _, msg = args[0] return u'|B|R%s|r\n' % msg else: return None