Exemplo n.º 1
0
 async def live_listen_list(self):
     group_id = self.group_id
     user_id = self.user_id
     if self.has_arg('room_id'):
         room_id = self.get('room_id')
         remind = self.find_remind(room_id)
         if remind:
             info = await remind.get_format_info()
             await self.send(info, no_delay=True)
         else:
             if is_number(room_id):
                 nl = await NBiliBiliLive(int(room_id))
                 (suc, msg) = await nl.check_room()
                 if not suc:
                     await self.send(msg, no_delay=True)
                 else:
                     info = await nl.check()
                     await self.send(info, no_delay=True)
             else:
                 await self.send('输入的好像不是数字哦')
     else:
         for r in self.remind_list:
             if group_id:
                 if r.has_group(group_id):
                     info = await r.get_format_info()
                     await self.send(info, no_delay=True)
                     await asyncio.sleep(0.8)
             elif r.has_user(user_id):
                 info = await r.get_format_info()
                 await self.send(info, no_delay=True)
                 await asyncio.sleep(0.8)
Exemplo n.º 2
0
    async def setu(self):
        # await self.send('暂时关闭')
        if self.group_id:
            requests_users: List[SetuConstruct] = last_request[self.group_id]
            user: SetuConstruct = next((user for user in requests_users if user.user_id == self.user_id), None)
            if user:
                if datetime.now() - user.request_time < timedelta(hours=1):
                    await self.send('你冲的太多啦!稍微休息一个小时吧')
                    return
                else:
                    user.request_time = datetime.now()
            else:
                requests_users.append(SetuConstruct(self.user_id, datetime.now()))

        num = int(self.get('num', required=False) or 1)
        if not is_number(num) or num < 1 or num > 3:
            num = 1
        with open(random_pixiv_file) as f:
            random_pixiv_ids = json.load(f)
        images = random.choices(random_pixiv_ids, k=num)
        for index, image_id in enumerate(images):
            while not await self.check_image(image_id):
                image_id = random.choice(random_pixiv_ids)
                images[index] = image_id
        for image_id in images:
            await self.send_image(f'https://pixiv.cat/{image_id}.jpg')
Exemplo n.º 3
0
 async def todays_fortune(self):
     (is_checkin, fortune) = await self.user.fortune
     if is_number(fortune):
         await self.send_image(fortune_list_image[int(fortune)])
     else:
         msg = f'今日运势:{fortune}, {fortune_list[fortune]}(随机抽取,仅供参考)'
         await self.send(msg, at_sender=True)
     if is_checkin:
         await self.send('顺手签到成功~~~积分+10', at_sender=True)
Exemplo n.º 4
0
 async def del_live_remind(self):
     room_id = self.get('room_id', prompt='房间id')
     group_id = self.group_id
     user_id = self.user_id
     if is_number(room_id):
         remind = self.find_remind(room_id)
         if remind and (remind.remove_group(group_id) if group_id else remind.remove_user(user_id)):
             await self.send('ok')
         else:
             await self.send('不在列表里')
     else:
         await self.send('输入的好像不是数字哦')
Exemplo n.º 5
0
 async def checkin(self):
     res = await self.user.checkin()
     if res is not False:
         if is_number(res):
             await self.send('签到成功~')
             await self.send_image(fortune_list_image[int(res)])
             return
         else:
             msg = f'签到成功,今日运势:{res}, {fortune_list[res]}(随机抽取,仅供参考)'
     else:
         msg = f'已经签到过了'
     await self.send(msg, at_sender=True)
Exemplo n.º 6
0
    async def add_live_remind(self):
        # get room_id
        room_id = self.get('room_id', prompt='房间id')
        # validate
        if is_number(room_id):
            remind = self.find_remind(room_id)
            # if exits in list
            if remind:
                if remind.has(group_id=self.group_id, user_id=self.user_id):
                    # already in
                    await self.send('已经在监听的列表里了')
                    return
                else:
                    # append
                    if self.group_id:
                        remind.append_group(self.group_id)
                    else:
                        remind.append_user(self.user_id)
            else:
                room_id = int(room_id)
                # check room exits
                nl = await NBiliBiliLive(room_id)
                (suc, msg) = await nl.check_room()
                if not suc:
                    await self.send(msg)
                    return

                # real room_id
                room_id = msg
                if self.group_id:
                    # init by group_id
                    remind = await BiliRemind(room_id, group_id=self.group_id)
                else:
                    # init by user_id
                    remind = await BiliRemind(room_id, user_id=self.user_id)
                # append to listen list
                self.remind_list.append(remind)
                await self.send('ok')
                await remind.check_send()
        else:
            await self.send('输入的好像不是数字哦')