def receive_group_msg(ctx: GroupMsg): num = 1 tag = '' info = re.findall(pattern, ctx.Content) if info: num = int(info[0][0] or 1) tag = info[0][1] if num > 5: Text('服了,要那么多干嘛,我只发5张!') num = 5 try: r = requests.get(api, params={'tag': tag, 'num': num}, timeout=10) except Exception: Text('老子出毛病了,稍后再试~') else: info = r.json() if info['count'] == 0: Text('没有没有,不要问了,没有!') else: for i in info['data']: action.send_group_pic_msg( ctx.FromGroupId, picUrl= 'https://cdn.jsdelivr.net/gh/laosepi/setu/pics_original/' + i['filename'], content=f"标题:{i['title']}\n作者: {i['author']}")
def receive_friend_msg(ctx: FriendMsg): # 好友图片消息 pic_ctx = refine.refine_pic_friend_msg(ctx) if pic_ctx is not None: print('----friend------------') Text(pic_ctx.GroupPic[0]['Url']) # 给他发送刚才图片的链接 del pic_ctx return # 好友语音消息 voice_ctx = refine.refine_voice_friend_msg(ctx) # 给他发送刚才语音的链接 if voice_ctx is not None: Text(voice_ctx.VoiceUrl) del voice_ctx return
def receive_group_msg(ctx): print('------------------') print(dir(ctx)) if hasattr(ctx, 'master'): print(ctx.master) print(type(ctx)) Text(ctx.master)
def receive_group_msg(ctx: GroupMsg): # 群红包消息 redbag_ctx = refine.refine_RedBag_group_msg(ctx) if redbag_ctx is not None: Text(redbag_ctx.RedBag_Authkey) # 如果是红包,就在刚才的群内发送刚才红包的`AuthKey`字段 del redbag_ctx return
def receive_group_msg(ctx: GroupMsg): userGroup = ctx.FromGroupId if(userGroup in blockGroupNumber): return c = ctx.Content if c.startswith('天气'): plugin_name = c[3:] print('keyWord------>'+plugin_name) response = requests.get('http://wthrcdn.etouch.cn/weather_mini?city='+str(plugin_name),timeout=10).text res = json.loads(response) if(res['status'] !=1000): Text('不支持查询的地点,请输入正确的城市名') else: '''获取时间表情''' now_ = datetime.now() hour = now_.hour minute = now_.minute now = hour + minute / 60 if 5.5 < now < 18: biaoqing = '[表情74]' else: biaoqing = '[表情75]' title = '\n'+biaoqing +'你正在查找的'+res['data']['city']+'的天气' todayWeather = '\n🔥'+res['data']['forecast'][0]['date']+'的天气:'+ res['data']['forecast'][0]['type']+''+returnWeatherBiaoqing(res['data']['forecast'][0]['type']) toMoWeather = '\n🔥'+res['data']['forecast'][1]['date']+'的天气:'+ res['data']['forecast'][1]['type']+''+returnWeatherBiaoqing(res['data']['forecast'][1]['type']) tips ='\n[表情89]体表温度为'+res['data']['wendu']+'℃\n💊群助手防感冒提醒你:'+ res['data']['ganmao'] returnContent =(title+''+todayWeather+''+toMoWeather+''+tips) Action(ctx.CurrentQQ).send_group_text_msg( ctx.FromGroupId, content=returnContent, atUser=ctx.FromUserId )
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId == ctx.CurrentQQ: return tag = re.findall(pattern, ctx.Content) tag = tag[0][1] if tag else '' try: r = requests.get(api, params={'tag': tag, 'num': 1}, timeout=10) except Exception: Text('老子出毛病了,稍后再试~') else: info = r.json() if info['count'] == 0: Text('没有没有,不要问了,没有!') else: Picture('https://cdn.jsdelivr.net/gh/laosepi/setu/pics_original/' + info['data'][0]['filename'])
def receive_group_msg(ctx: GroupMsg): content = ctx.Content if len(content) < 30: big_mouth_deque.append(content) if len(set(big_mouth_deque)) == 1: Text(content) for i in range(big_mouth_len): big_mouth_deque.append(i)
def receive_group_msg(ctx: GroupMsg): try: rep = requests.get('https://v1.jinrishici.com/all.json', timeout=10) rep.raise_for_status() content: str = rep.json()['content'] origin: str = rep.json()['origin'] author: str = rep.json()['author'] temp = [origin, f'【{author}】', content] max_len = max([len(x) for x in temp]) Text('\n'.join([x.center(max_len) for x in temp])) except Exception as e: print(e)
def receive_group_msg(ctx: GroupMsg): if ctx.MsgType == MsgTypes.TextMsg: if not ctx.Content.startswith('复读机'): return text = ctx.Content[3:] # type: str while '复读机' in text: # 防止别人搞鬼发这种东西: 复读机复复读机读复读机机 text = text.replace('复读机', '') if text: Text(text) elif ctx.MsgType == MsgTypes.PicMsg: pic_ctx = refine_pic_group_msg(ctx) if pic_ctx is None: return for pic in pic_ctx.GroupPic: Picture(pic_url=pic.Url) sleep(1) elif ctx.MsgType == MsgTypes.AtMsg: # TODO pass
def receive_group_msg(ctx: GroupMsg): if ctx.Content == '开关防撤回' and ctx.FromUserId in admins: if FLAG.exists(): # 存在说明开启状态,则关闭。 os.remove(FLAG) else: FLAG.touch() Text('ok') # 储存消息 if ctx.MsgType in [MsgTypes.TextMsg, MsgTypes.PicMsg, MsgTypes.AtMsg]: db.insert_one({ 'msg_type': ctx.MsgType, 'msg_random': ctx.MsgRandom, 'msg_seq': ctx.MsgSeq, 'msg_time': ctx.MsgTime, 'user_id': ctx.FromUserId, 'user_name': ctx.FromNickName, 'group_id': ctx.FromGroupId, 'content': ctx.Content, })
def receive_group_msg(ctx: GroupMsg): userGroup = ctx.FromGroupId if (userGroup in blockGroupNumber): return qq = ctx.FromUserId c = ctx.Content if (c.startswith('#赞我')): f = read(ctx.FromUserId) if (f == 0): Action(ctx.CurrentQQ).send_group_text_msg( ctx.FromGroupId, content='正在赞~~请稍等,大概花费30s左右', atUser=ctx.FromUserId) nowTime = returnDate() save(nowTime, ctx.FromUserId) for i in range(50): Action(ctx.CurrentQQ).like(ctx.FromUserId) time.sleep(0.4) Action(ctx.CurrentQQ).send_group_text_msg(ctx.FromGroupId, content='赞好啦~请查收', atUser=ctx.FromUserId) else: if (isToday(f) == 1): Text('你已经赞过了,请明天在来吧~') else: Action(ctx.CurrentQQ).send_group_text_msg( ctx.FromGroupId, content='正在赞~~请稍等,大概花费30s左右', atUser=ctx.FromUserId) nowTime = returnDate() save(nowTime, ctx.FromUserId) for i in range(50): Action(ctx.CurrentQQ).like(ctx.FromUserId) time.sleep(0.4) Action(ctx.CurrentQQ).send_group_text_msg( ctx.FromGroupId, content='赞好啦~请查收', atUser=ctx.FromUserId)
def receive_friend_msg(_): Text(sysinfo())
def receive_group_msg(_): Text(sysinfo())
def receive_group_msg(ctx: GroupMsg): if ctx.Content.startswith('?'): text = ctx.Content[1:] ret = whatis(text) if ret: Text(ret)
def receive_friend_msg(_): Text(get_msg())
def receive_group_msg(_): Text(get_msg())