コード例 #1
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def recheck_cb(_, update, groups):
    logger.info('recheck inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    torrent.recheck()

    update.callback_query.answer('Re-check started')
コード例 #2
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def max_priority_cb(_, update, groups):
    logger.info('max priority inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    torrent.max_priority()

    update.callback_query.answer('Max priority set')
コード例 #3
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def on_info_deeplink(_, update, groups=[]):
    logger.info('info deeplink from %s', update.message.from_user.first_name)

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)

    update.message.reply_html(torrent.string(),
                              reply_markup=torrent.short_markup())
コード例 #4
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def priority_up_cb(_, update, groups):
    logger.info('priority up inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    torrent.increase_priority()

    update.callback_query.answer('Increased priority')
コード例 #5
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def unforce_start_torrent_cb(_, update, groups):
    logger.info('unforce start torrent inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    torrent.toggle_force_start(False)

    update.callback_query.answer('Force-start set to "false"')
コード例 #6
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def resume_torrent_cb(_, update, groups):
    logger.info('resume torrent inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    torrent.resume()

    update.callback_query.answer('Resumed')
コード例 #7
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def pause_torrent_cb(_, update, groups):
    logger.info('pause torrent inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    torrent.pause()

    update.callback_query.answer('Paused')
コード例 #8
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def confirm_delete_with_files_cb(_, update, groups):
    logger.info('confirmation delete with files inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    torrent.delete(with_files=True)

    update.callback_query.edit_message_text('{} deleted (with files)'.format(
        torrent.name))
コード例 #9
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def force_resume_torrent_cb(_, update, groups):
    logger.info('force-resume torrent inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    torrent.resume()
    time.sleep(1)
    torrent.toggle_force_start(True)

    update.callback_query.answer('Force-resumed')
コード例 #10
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def manage_torrent_cb(_, update, groups):
    logger.info('manage torrent inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)

    update.callback_query.edit_message_text(
        torrent.string(refresh_properties=True),
        reply_markup=torrent.actions_keyboard,
        parse_mode=ParseMode.HTML)
    update.callback_query.answer('Use the keyboard to manage the torrent')
コード例 #11
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def reduce_buttons(_, update, groups):
    logger.info('remove buttons inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)

    update.callback_query.edit_message_text(
        torrent.string(refresh_properties=True),
        reply_markup=torrent.short_markup(),
        parse_mode=ParseMode.HTML)
    update.callback_query.answer('Inline keyboard reduced')
コード例 #12
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def ask_confirm_delete_with_files_cb(_, update, groups):
    logger.info('delete with files inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    # torrent.delete(with_files=True)

    update.callback_query.edit_message_text(
        'Are you sure you want to delete {}, <b>with all the connected files included</b>?'
        .format(u.html_escape(torrent.name)),
        reply_markup=kb.confirm_delete(torrent.hash),
        parse_mode=ParseMode.HTML)
    update.callback_query.answer('Confirmation needed')
コード例 #13
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def refresh_torrent_cb(_, update, groups):
    logger.info('refresh torrent inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)

    try:
        update.callback_query.edit_message_text(
            torrent.string(),
            reply_markup=torrent.actions_keyboard,
            parse_mode=ParseMode.HTML)
    except BadRequest as e:
        logger.info('bad request: %s', e.message)

    update.callback_query.answer('Torrent info refreshed')
コード例 #14
0
ファイル: manage.py プロジェクト: pcskys/qbittorrent-bot
def see_trackers_cb(_, update, groups):
    logger.info('trackers inline button')

    torrent_hash = groups[0]
    logger.info('torrent hash: %s', torrent_hash)

    torrent = qb.torrent(torrent_hash)
    trackers = torrent.trackers()

    strings_list = [
        '<b>{status}:</b> {url} <b>({num_peers})</b>'.format(
            **{k: u.html_escape(str(v))
               for k, v in tracker.items()}) for tracker in trackers
    ]
    text = '\n'.join(strings_list)

    if len(text) > MAX_MESSAGE_LENGTH:
        trackers_info = dict()
        for tracker in trackers:
            if not trackers_info.get(tracker['status'], None):
                trackers_info[tracker['status']] = dict(count=0, num_peers=0)

            trackers_info[tracker['status']]['count'] += 1
            trackers_info[
                tracker['status']]['num_peers'] += tracker['num_peers']

        lines_list = list()
        for status, status_counts in trackers_info.items():
            lines_list.append('<b>{}</b>: {} trackers, {} peers'.format(
                status, status_counts['count'], status_counts['num_peers']))

        text = '\n'.join(lines_list)

    update.callback_query.edit_message_text(
        text or 'No trackers',
        reply_markup=torrent.actions_keyboard,
        parse_mode=ParseMode.HTML,
        disable_web_page_preview=True)
    update.callback_query.answer('Trackers list')