コード例 #1
0
ファイル: core.py プロジェクト: dalor/dpixivbot
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()
コード例 #2
0
 def shared_reply(self, pic_id, ppic=0):
     new_pic_id = pic_id if not ppic else '{}_{}'.format(pic_id, ppic)
     return [[
         button('Source', url='https://www.pixiv.net/member_illust.php?mode=medium&illust_id={}'.format(pic_id)),
         button('More', url='t.me/{}?start={}'.format(self.BOTNAME, new_pic_id)),
         button('Share', switch_inline_query=new_pic_id)
         ]]
コード例 #3
0
 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()
コード例 #4
0
 def navbar(self, count, nav_text, buttons=[]):
     if count > 10:
         buttons = [
             button('<', callback_data='{} <'.format(nav_text))
         ] + buttons + [button('>', callback_data='{} >'.format(nav_text))]
     if count > 100:
         buttons = [button('<<', callback_data='{} <<'.format(nav_text))
                    ] + buttons + [
                        button('>>', callback_data='{} >>'.format(nav_text))
                    ]
     if count > 1000:
         buttons = [button(
             '<<<', callback_data='{} <<<'.format(nav_text))] + buttons + [
                 button('>>>', callback_data='{} >>>'.format(nav_text))
             ]
     return buttons
コード例 #5
0
 def main_menu(self, source, id):
     return [[
         button('Volumes', callback_data='vls {} {} 0 -'.format(source, id))
     ], [button('Download', callback_data='d {} {}'.format(source, id))]]
コード例 #6
0
ファイル: core.py プロジェクト: dalor/dpixivbot
def reply_markup_for_gifhelp(id_=None):
    return [[button(GIF_HELP[i]['name'], callback_data='help {}'.format(i))]
            for i in range(len(GIF_HELP)) if i != id_]
コード例 #7
0
 def reply(self, args):
     reply_result = []
     params = args.format()
     pic_id = int(args.pic_id)
     if pic_id > 10000:
         if args.mppic > 1:
             reply_result.append([
                 button('◀️', callback_data='prev {}'.format(params)),
                 button('▶️', callback_data='next {}'.format(params))
                 ])
         reply_result.append([
             button('Source', url='https://www.pixiv.net/member_illust.php?mode=medium&illust_id={}'.format(pic_id)),
             button('Download file', callback_data='file'),
             button('Share', switch_inline_query=pic_id if not args.ppic else '{}_{}'.format(pic_id, args.ppic)),
             button('🔽', callback_data='show {}'.format(params)) 
             if not args.show else button('🔼', callback_data='hide {}'.format(params))
             ])
     elif pic_id <= 11 and pic_id >= 1: #For ranking
         reply_result.extend([[button(('✅ ' if pic_id == btn else '') + self.ranking[btn]['name'], callback_data='rank {} m{}'.format(params, btn)) for btn in btn_line] for btn_line in self.ranking_buttons])
     if args.show or pic_id < 10001:
         reply_result.append([
             button('➖', callback_data='count_minus {}'.format(params)),
               button('{} ⬇️'.format(args.count), callback_data='similar {}'.format(params)),
               button('➕', callback_data='count_plus {}'.format(params)),
               button('🖼' if args.only_pics else '📰', callback_data='opics {}'.format(params)),
               button('📄' if args.by_one else '📂', callback_data='group {}'.format(params))
               ])
     return reply_result