def login_url(a): a.msg('Use this browser extension to log in your pixiv account', reply_markup=markup([[ button( '🦊Firefox (Also for Android)', url='https://addons.mozilla.org/en-US/firefox/addon/dpixiv/') ], [button('Chrome (Later)', url='https://google.com')]])).send()
def spec_help(a): id_ = int(a.args[1]) help_ = GIF_HELP[id_] b.editmedia(imanimation(help_['file_id'], caption=help_['name']), chat_id=a.data['message']['chat']['id'], message_id=a.data['message']['message_id'], reply_markup=markup(reply_markup_for_gifhelp(id_))).send()
async def content_list(self, chat_id, message_id, id, page, source, volumes, turn=None): lines_count = 0 lines = [] for vol in volumes: lines.append(vol) if vol.choosen: lines.extend(vol.chapters) lines_count += (2 + len(vol.chapters)) else: lines_count += 1 if turn: pages = lines_count // self.per_page + 1 vector = self.nav_codes(turn) start_page = pages + page + vector if page + vector < 0 else page + vector if page + vector < pages else page + vector - pages else: start_page = page start = start_page * self.per_page end = None if start + self.per_page > lines_count else start + self.per_page buttons_lines = [] for line in lines[start:end]: if line.type == 'chapter': buttons_lines.append([ button('{} {}: {}'.format('✅' if line.choosen else '📑', line.id, line.title), callback_data='c{} {} {} {}'.format( 0 if line.choosen else 1, source, id, line.id)) ]) elif line.type == 'volume': buttons_lines.append([ button('📁 Volume {}'.format(line.id), callback_data='v{} {} {} {}'.format( 0 if line.choosen else 1, source, id, line.id)) ]) if line.choosen: buttons_lines.append([ button('Choose all'.format(line.id), callback_data='c_all {} {} {}'.format( source, id, line.id)) ]) buttons = [[ button('< To main', callback_data='main mangalib {}'.format(id)) ]] + buttons_lines + [ self.navbar(lines_count, 'vls mangalib {} {}'.format( id, start_page), [ button(start_page + 1, callback_data='page {} {}'.format( start_page, self.per_page)) ]) ] await self.bot.editreplymarkup(chat_id=chat_id, message_id=message_id, reply_markup=markup(buttons)).send()
def send_to_channel(self, a, by_tag=False): pixiv_id = self.find_pixiv_id_in_mess(a.data) if by_tag else a.args if pixiv_id: picture = self.get_pix(None).info(pixiv_id[1]) ppic = int(pixiv_id[2]) if pixiv_id[2] else 0 pic = self.prepare_picture(picture, ppic) self.b.more([ a.photo(pic['url'], reply_markup=markup(self.channel_reply(pixiv_id[1], ppic))), a.delete()])
async def send_manga(self, chat_id, source, id, thumbnail, name, other_name, lang, description, chapters, volumes): await self.bot.photo( thumbnail, chat_id=chat_id, caption= '<b>{}\n{}[{}]</b>\n{}\nVolumes: <code>{}</code>\nChapters: <code>{}</code>' .format(name, other_name, lang, description, len(volumes), len(chapters)), parse_mode='HTML', reply_markup=markup(self.main_menu(source, id))).send()
def send_picture(self, pic_id, chat_id, ppic=0, reply_to_message_id=None, is_desc=True, pix=None): pix = self.get_pix(chat_id) if not pix else pix pic_info = pix.info(pic_id) if pic_info: reply_args = Parameters(pic_id=pic_id, mppic=pic_info['pageCount'], ppic=ppic if ppic < pic_info['pageCount'] and ppic > 0 else 0, count=pix.count, only_pics=pix.only_pics, by_one=pix.by_one) pic = self.prepare_picture(pic_info, reply_args.ppic) reply_markup = markup(self.reply(reply_args)) if is_desc else '' result = self.b.photo(pic['url'], chat_id=chat_id, caption=pic['caption'] if is_desc else '', parse_mode='HTML', reply_to_message_id=reply_to_message_id if reply_to_message_id else '', reply_markup=reply_markup).send() if not result['ok'] and is_desc: self.b.msg(pic['caption'], chat_id=chat_id, parse_mode='HTML', reply_to_message_id=reply_to_message_id if reply_to_message_id else '', reply_markup=reply_markup).send() return True
def change_pic(self, a, s): args = self.parse_args(a) npic = args.ppic + s mppic = args.mppic entities = None; text = None message = a.data['message'] is_photo = False if 'caption_entities' in message: is_photo = True entities = message['caption_entities'] text = message['caption'] elif 'entities' in message: entities = message['entities'] text = message['text'] if npic >= mppic: npic = 0 elif npic < 0: npic = mppic - 1 if not entities or not text: return 'Nothing' temp_pic_url = self.change_url_page(entities[0]['url'], npic) entities[0]['url'] = temp_pic_url caption = self.return_format_to_text(text, entities) caption = caption.replace('({}/{})\n'.format(args.ppic + 1, mppic), '({}/{})\n'.format(npic + 1, mppic)) pic_url = get_clear_pic_url.match(temp_pic_url)[1].replace('_p{}'.format(npic), '_p{}_master1200'.format(npic)).replace('img-original', 'img-master').replace('.png', '.jpg') args.ppic = npic reply_markup = markup(self.reply(args)) if is_photo: result = self.b.editmedia( imphoto(pic_url, caption=caption, parse_mode='HTML'), chat_id=a.data['message']['chat']['id'], message_id=a.data['message']['message_id'], reply_markup=reply_markup).send() if not result['ok']: return None else: self.b.edittext(caption, parse_mode='HTML', chat_id=a.data['message']['chat']['id'], message_id=a.data['message']['message_id'], reply_markup=reply_markup).send() return '{}/{}'.format(npic + 1, mppic)
async def back_to_main(self, source, id, chat_id, message_id): await self.bot.editreplymarkup(chat_id=chat_id, message_id=message_id, reply_markup=markup( self.main_menu(source, id))).send()
def help_in_gif(a): id_ = 0 a.animation(GIF_HELP[id_]['file_id'], caption=GIF_HELP[id_]['name'], reply_markup=markup(reply_markup_for_gifhelp(id_))).send()
def change_default_settings(self, a, pix): reply_args = Parameters(pic_id='0', count=pix.count, only_pics=pix.only_pics, by_one=pix.by_one) a.msg('<b>Change default settings</b>\nPress ⬇️ to save', parse_mode='HTML', reply_markup=markup(self.reply(reply_args))).send()
def send_ranking_list(self, a): pix = self.get_pix(a.data['chat']['id']) reply_args = Parameters(pic_id='1', count=pix.count, only_pics=pix.only_pics, by_one=pix.by_one) a.msg('<b>Rankings:</b>', parse_mode='HTML', reply_markup=markup(self.reply(reply_args))).send()
def edit_reply_for_callback(self, a, reply): self.b.editreplymarkup(chat_id=a.data['message']['chat']['id'], message_id=a.data['message']['message_id'], reply_markup=markup(reply)).send()