def getModian(delay): bot = CQHttp(api_root='http://127.0.0.1:5700/') while True: stampTime = int(time.time()) msgDict = newOrder(stampTime, int(delay)) if msgDict: for msg in msgDict['msg']: msg += msgDict['end'] bot.send_group_msg_async(group_id=groupid(), message=msg, auto_escape=False) time.sleep(0.1) time.sleep(int(delay))
def getModian(): # try: # INFO('check modian') stampTime = int(time.time()) msgDict_arr = newOrder(stampTime, int(interval_md)) for msgDict in msgDict_arr: if msgDict: for msg in msgDict: for grpid in groupid(): bot.send_group_msg_async(group_id=grpid, message=msg, auto_escape=False) time.sleep(0.1)
def mytask(bot): gl = bot.List('group', groupid) if gl is not None: for group in gl: # 获取当前unix时间(10位,单位为秒) stampTime = int(time.time()) # 调用modian.py的newOrder方法 # 第二个参数是查询时间段:60即查询当前时间前60s得新集资 # 若修改了查询频率,则一定要修改第二个参数 msgDict = modian.newOrder(stampTime, 60) # 返回了一个字典 if msgDict: for msg in msgDict['msg']: msg += msgDict['end'] bot.SendTo(group, msg)
def getModian(): # bot = CQHttp(api_root='http://127.0.0.1:5700/') try: # INFO(printStrTime() + 'check modian') INFO('check modian') stampTime = int(time.time()) msgDict_array = newOrder(stampTime, int(interval_md)) for msgDict in msgDict_array: if msgDict: for msg in msgDict['msg']: msg += msgDict['end'] # print(printStrTime() + msg) bot.send_group_msg_async(group_id=groupid(), message=msg, auto_escape=False) time.sleep(0.1) except Exception as e: WARN('error when getModian') finally: # INFO(printStrTime() + 'modian check completed') INFO('modian check completed')
def getmodian(self): try: INFO('check modian') stampTime = int(time.time()) msgDict_array = newOrder(stampTime, int(self.interval_md)) for msgDict in msgDict_array[0:-1]: if msgDict: for msg in msgDict['msg']: msg += msgDict['end'] print(msg) for grpid in self.pref3.getqqidarray(): self.bot.send_group_msg_async(group_id=grpid, message=msg, auto_escape=False) time.sleep(0.1) except Exception as e: WARN('error when getModian', e, "modian dict:", msgDict_array[-1]) finally: INFO('modian check completed')