def onQQMessage(bot, contact, member, content): if contact.ctype == 'group' and contact.nick == groupid: if content == 'wds' or content == '集资' or content == 'jz' or content == '打卡' or content == 'dk': jz = '' jz = jz + setting.wds_name() + '\n' + setting.wds_url() bot.SendTo(contact, str(jz)) elif content == 'wds20' or content == 'jz20' or content == 'rank' or content == '聚聚榜' or content == 'jzb' or content == '集资榜': bot.SendTo(contact, modian.rank(1)) elif content == 'dkb' or content == '打卡榜' or content == 'dk20' or content == 'dakabang': bot.SendTo(contact, modian.rank(2)) elif content == "独占": duzhan = "独占请集资" + '\n' + setting.wds_name() + '\n' + setting.wds_url() bot.SendTo(contact, duzhan) # elif content == "想39": # xiang39 = "补档请看" + '\n' + "http://t.cn/RCbRLjZ" # bot.SendTo(contact, xiang39) # elif content == "剁椒鱼头": # duojiaoyutou = "我们都爱剁椒鱼头" # bot.SendTo(contact, duojiaoyutou) elif content == "欢迎新人": welcome = setting.welcome() bot.SendTo(contact, welcome) elif content == "help": help = '''废物机器人口令帮助:\n“集资”或“打卡”:返回集资地址"\n“集资榜”或“jzb”:返回集资金额榜单\n“打卡榜”或“dkb”:返回打卡天数榜单\n''' bot.SendTo(contact, help)
def task(bot): global firstcheck new_member = [] # g is list g = bot.List('group', groupid) if firstcheck is True: bot.Update(g[0]) firstcheck = False if g is None: WARN('向 QQ 服务器请求联系人列表和资料失败') elif not g: INFO('该联系人列表内没有和 cinfo 匹配的联系人') elif g: # group_* is object ml_old = copy.copy(bot.List(g[0])) # update group_member list if bot.Update(g[0]): ml_latest = copy.copy(bot.List(g[0])) if len(ml_latest) > len(ml_old): for mb in map(str, ml_latest): if mb not in map(str, ml_old): new_member.append(mb) for group in g: msg = '欢迎' if (len(ml_latest) - len(ml_old)) < len(new_member): msg += str(len(ml_latest) - len(ml_old)) + '位新聚聚加入本群' else: for vl in new_member: msg += '新' + str(vl) msg += '加入本群' bot.SendTo(group, msg) bot.SendTo(group, setting.welcome()) new_member = [] else: WARN('更新联系人列表和资料失败')
def handle_group_increase(context): if context['group_id'] == setting.groupid()[0]: welcome = [{'type': 'text', 'data': {'text': '欢迎新聚聚:'}}, {'type': 'at', 'data': {'qq': str(context['user_id'])}}, {'type': 'text', 'data': {'text': ' 加入本群\n\n%s' % setting.welcome()}} ] bot.send(context, message=welcome, is_raw=True) # 发送欢迎新人
def handle_msg(context): if context['group_id'] == setting.groupid( ) and context['user_id'] != context['self_id']: if setting.shutup(): for word in setting.shutup(): if word in context['message']: bot.set_group_ban(group_id=setting.groupid(), user_id=context['user_id'], duration=30 * 60) if context['message'] == '集资' or context['message'] == 'jz' or context[ 'message'] == '打卡' or context['message'] == 'dk': jz = '' jz += setting.wds_name() + '\n' + setting.wds_url() bot.send(context, jz) elif context['message'] == 'wds20' or context[ 'message'] == 'jz20' or context['message'] == 'rank' or context[ 'message'] == '聚聚榜' or context[ 'message'] == 'jzb' or context['message'] == '集资榜': bot.send(context, modian.rank(1)) elif context['message'] == 'dkb' or context[ 'message'] == '打卡榜' or context['message'] == 'dk20' or context[ 'message'] == 'dakabang': bot.send(context, modian.rank(2)) elif "独占" in context['message']: duzhan = "独占请集资" + '\n' + setting.wds_name( ) + '\n' + setting.wds_url() bot.send(context, duzhan) elif context['message'] == '欢迎新人': bot.send(context, setting.welcome()) elif context['message'] == '项目进度' or context['message'] == '进度': jd = modian.result(setting.pro_id()) + '\n' + setting.wds_url() bot.send(context, jd)
def handle_msg(context): if context['group_id'] == setting.groupid( ) and context['user_id'] != context['self_id']: # 关键词禁言 if setting.shutup(): for word in setting.shutup(): if word in context['message']: bot.set_group_ban(group_id=setting.groupid(), user_id=context['user_id'], duration=30 * 60) # 关键词回复 if context['message'] == '集资' or context['message'] == 'jz' or context[ 'message'] == '打卡' or context['message'] == 'dk': jz = '' jz_array = modian.md_init(setting.pro_id()) for jz_dict in jz_array: jz += jz_dict['name'] + '\n' + jz_dict['url_short'] + '\n' bot.send(context, jz) elif context['message'] == 'wds20' or context[ 'message'] == 'jz20' or context['message'] == 'rank' or context[ 'message'] == '聚聚榜' or context[ 'message'] == 'jzb' or context['message'] == '集资榜': rank1_array = modian.rank(1) for rank1_msg in rank1_array: bot.send(context, rank1_msg) elif context['message'] == 'dkb' or context[ 'message'] == '打卡榜' or context['message'] == 'dk20' or context[ 'message'] == 'dakabang': rank2_array = modian.rank(2) for rank2_msg in rank2_array: bot.send(context, rank2_msg) elif "独占" in context['message']: dz = '' dz_array = modian.md_init(setting.pro_id()) for dz_dict in dz_array: dz += dz_dict['name'] + '\n' + dz_dict['url_short'] + '\n' duzhan = "独占请集资" + '\n' + dz bot.send(context, duzhan) elif context['message'] == '欢迎新人': bot.send(context, setting.welcome()) elif context['message'] == '项目进度' or context['message'] == '进度': jd_array = modian.result(setting.pro_id()) jd = '' for jd_msg in jd_array: jd += jd_msg + '\n' bot.send(context, jd)
def handle_group_increase(context): if context['group_id'] == setting.groupid(): # ret = bot.get_stranger_info(user_id=context['user_id'], no_cache=False) # welcome = '欢迎新聚聚:@' + ret['nickname'] + ' 加入本群\n\n' + setting.welcome() welcome = [{ 'type': 'text', 'data': { 'text': '欢迎新聚聚:' } }, { 'type': 'at', 'data': { 'qq': str(context['user_id']) } }, { 'type': 'text', 'data': { 'text': '加入本群\n\n%s' % setting.welcome() } }] bot.send(context, message=welcome, is_raw=True) # 发送欢迎新人
def handle_group_increase(context): ret = bot.get_stranger_info(user_id=context['user_id'], no_cache=False) welcome = '欢迎新聚聚:@' + ret['nickname'] + ' 加入本群\n' + setting.welcome() bot.send(context, message=welcome, is_raw=True) # 发送欢迎新人