def receive_group_msg(ctx: GroupMsg): if ctx.Content.startswith('ph '): args = [i.strip() for i in ctx.Content.split(' ') if i.strip()] if len(args) >= 3: left = args[1] right = args[2] f = combine_img_horizontal if len(args) >= 4: if args[3] == '1': f = combine_img_vertical Picture(pic_base64=f(left, right))
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): 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_friend_msg(ctx: FriendMsg): Picture(pic_base64=gen_qrcode(ctx.Content.replace('生成二维码', '')))
def receive_group_msg(ctx: GroupMsg): Picture(pic_base64=gen_qrcode(ctx.Content.replace('生成二维码', '')))