def rank(type): msg = '' err = False err_msg = '返回rank错误\n' detail = getDetail(str(setting.pro_id())) # type=1:总额榜 if type == 1: msg = msg + setting.wds_name() + '·聚聚榜TOP20\n' + '------------\n' dic = getRankings(setting.pro_id(), 1, 1) if int(dic['status']) == 0: for data in dic['data']: msg = msg + '【第' + str(data['rank']) + '名】: ' +data['nickname'] + '支持了' + str(data['backer_money']) + '元\n' elif int(dic['status']) == 2: err = True err_msg += dic['message'] elif type == 2: msg = msg + setting.wds_name() + '·打卡榜TOP20\n' + '------------\n' dic = getRankings(setting.pro_id(), 2, 1) if int(dic['status']) == 0: for data in dic['data']: msg = msg + '【第' + str(data['rank']) + '名】: ' +data['nickname'] + '已打卡' + str(data['support_days']) + '天\n' elif int(dic['status']) == 2: err = True err_msg += dic['message'] msg = msg + '【摩点】:' + setting.wds_url() + '\n目前集资进度:¥' +\ str(detail['data'][0]['already_raised']) + '\n目标:¥' +\ detail['data'][0]['goal'] if err is True: return err_msg elif err is False: return msg
def rank(type): msg = '' err = False err_msg = '返回rank错误\n' detail = getDetail(str(setting.pro_id())) # type=1:总额榜 if type == 1: msg = msg + setting.wds_name() + '·聚聚榜TOP20\n' + '------------\n' dic = getRankings(setting.pro_id(), 1, 1) if int(dic['status']) == 0: for data in dic['data']: msg = msg + '【第' + str( data['rank']) + '名】: ' + data['nickname'] + '支持了' + str( data['backer_money']) + '元\n' elif int(dic['status']) == 2: err = True err_msg += dic['message'] elif type == 2: msg = msg + setting.wds_name() + '·打卡榜TOP20\n' + '------------\n' dic = getRankings(setting.pro_id(), 2, 1) if int(dic['status']) == 0: for data in dic['data']: msg = msg + '【第' + str( data['rank']) + '名】: ' + data['nickname'] + '已打卡' + str( data['support_days']) + '天\n' elif int(dic['status']) == 2: err = True err_msg += dic['message'] msg = msg + '【摩点】:' + setting.wds_url() + '\n目前集资进度:¥' +\ str(detail['data'][0]['already_raised']) + '\n目标:¥' +\ detail['data'][0]['goal'] if err is True: return err_msg elif err is False: return msg
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 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 newOrder(stamp10, secondsDelay): newOrders = [] orderDict = getOrders(setting.pro_id(), 1) if int(orderDict['status']) == 2: return orderDict['message'] for data in orderDict['data']: pay_time = data['pay_time'] data['pay_time'] = int(time.mktime(time.strptime(pay_time, '%Y-%m-%d %H:%M:%S'))) if data['pay_time'] >= stamp10 - secondsDelay and data['pay_time'] < stamp10: newOrders.append(data) msgDict = {} if newOrders: detail = getDetail(setting.pro_id()) if int(detail['status']) == 2: return detail['message'] msgDict['msg'] = [] msg = '' for newOrder in newOrders: msg = "感谢 " + newOrder['nickname'] +\ " 聚聚在【" + setting.wds_name() + "】中支持了 ¥" +\ str(newOrder['backer_money']) + '\n' msgDict['msg'].append(msg) msgDict['end'] = '【摩点】:' + setting.wds_url() + '\n目前集资进度:¥' +\ str(detail['data'][0]['already_raised']) + '\n目标:¥' +\ str(detail['data'][0]['goal']) return msgDict
def newOrder(stamp10, secondsDelay): newOrders = [] # 获取一次订单信息,返回一个dictionary orderDict = getOrders(setting.pro_id(), 1) # 查询失败则返回错误信息 if int(orderDict['status']) == 2: return orderDict['message'] # 查询成功,遍历data for data in orderDict['data']: pay_time = data['pay_time'] # 将字符串时间转换为unix时间戳 data['pay_time'] = int(time.mktime(time.strptime(pay_time, '%Y-%m-%d %H:%M:%S'))) # 筛选订单时间在查询时间前的设定时间段之间的订单 if data['pay_time'] >= stamp10 - secondsDelay and data['pay_time'] < stamp10: newOrders.append(data) msgDict = {} # 有新订单 if newOrders: # 获取项目信息 detail = getDetail(setting.pro_id()) # 查询失败则返回错误信息 if int(detail['status']) == 2: return detail['message'] # 查询成功,初始化消息 msgDict['msg'] = [] msg = '' for newOrder in newOrders: msg = "感谢 " + newOrder['nickname'] +\ " 聚聚在【" + setting.wds_name() + "】中支持了 ¥" +\ str(newOrder['backer_money']) + '\n' msgDict['msg'].append(msg) msgDict['end'] = '【摩点】:' + setting.wds_url() + '\n目前集资进度:¥' +\ str(detail['data'][0]['already_raised']) + '\n目标:¥' +\ str(detail['data'][0]['goal']) return msgDict
def onQQMessage(bot, contact, member, content): if contact.ctype == 'group' and contact.nick == groupid: if content == '打卡': jz = '' jz = jz + setting.wds_name() + '\n' + setting.wds_url() bot.SendTo(contact, str(jz)) elif content == 'wds20' or content == 'rank': bot.SendTo(contact, modian.rank(1)) elif content == 'dkb' or content == '打卡榜': bot.SendTo(contact, modian.rank(2)) elif content == "独占": duzhan = "独占请集资" + '\n' + setting.wds_name( ) + '\n' + setting.wds_url() bot.SendTo(contact, duzhan) elif content == "help": help = '''Nemo操作手册:\n摩点相关\n1.“打卡”:返回集资地址"\n2.“rank”或“wds20”:返回集资金额榜单\n3.“打卡榜”或“dkb”:返回打卡天数榜单\n\n查询类\n1."集资查询+ID"返回某一ID的集资总额(数据每个月更新一次)\n2."我的2017+ID"返回2017年度账单\n3."微博故事+费沁源(或UID)"返回微博故事下载链接\n(注:所有查询类请求格式均为"命令+冒号+参数(ID))''' bot.SendTo(contact, help)
def diff(num): detail = getDetail(str(setting.pro_id())) msg = '' if num > 20: num = 20 order = getOrders(setting.pro_id(), 1) if int(order['status']) == 2: return order['message'] for i in range(0, num): msg += "ID: " + order['data'][i]['nickname'] +\ " 的聚聚刚刚在【" + setting.wds_name() + "】中支持了 ¥" +\ str(order['data'][i]['backer_money']) + '\n' + "感谢这位聚聚对" +\ setting.idol_name() + "的支持" + '\n' msg += '【摩点】:' + setting.wds_url() + '\n目前集资进度:¥' +\ str(detail['data'][0]['already_raised']) + '\n目标:¥' +\ str(detail['data'][0]['goal']) return msg
def newOrder(stamp10, secondsDelay): newOrders = [] # 获取一次订单信息,返回一个dictionary orderDict = getOrders(setting.pro_id(), 1) # 查询失败则返回错误信息 if int(orderDict['status']) == 2: return orderDict['message'] # 查询成功,遍历data for data in orderDict['data']: pay_time = data['pay_time'] # 将字符串时间转换为unix时间戳 data['pay_time'] = int(time.mktime(time.strptime(pay_time, '%Y-%m-%d %H:%M:%S'))) # 筛选订单时间在查询时间前的设定时间段之间的订单 if data['pay_time'] >= stamp10 - secondsDelay and data['pay_time'] < stamp10: newOrders.append(data) msgDict = {} # 有新订单 if newOrders: # 获取项目信息 detail = getDetail(setting.pro_id()) # 查询失败则返回错误信息 if int(detail['status']) == 2: return detail['message'] # 查询成功,初始化消息 msgDict['msg'] = [] msg = '' for newOrder in newOrders: msg = "ID: " + newOrder['nickname'] +\ " 的聚聚刚刚在【" + setting.wds_name() + "】中支持了 ¥" +\ str(newOrder['backer_money']) + '\n' + "感谢这位聚聚对" +\ setting.idol_name() + "的支持" + '\n' msgDict['msg'].append(msg) msgDict['end'] = '【摩点】:' + setting.wds_url() + '\n目前集资进度:¥' +\ str(detail['data'][0]['already_raised']) + '\n目标:¥' +\ str(detail['data'][0]['goal']) return msgDict