Exemplo n.º 1
0
    def handler(self, bot, update, *args, **kwargs):
        """
        After the user clicked on the page number to be displayed, the handler
        generates a message with the data from the specified page, creates
        a new keyboard and modifies the last message (the one under which
        the key with the page number was pressed)
        """
        scope = get_query_scope(update)
        key, page = self.get_issue_data(scope['data'])
        user_data = self.app.db.get_cached_content(key=key)

        if not user_data:
            text = 'Cache for this content has expired. Repeat the request, please'
            return self.app.send(bot, update, text=text)

        title = user_data['title']
        items = user_data['content'][page - 1]
        page_count = user_data['page_count']
        self.app.send(bot,
                      update,
                      title=title,
                      items=items,
                      page=page,
                      page_count=page_count,
                      key=key)
Exemplo n.º 2
0
    def handler(self, bot, update, *args, **kwargs):
        """Deletes user credentials from DB"""
        scope = get_query_scope(update)
        answer = scope['data'].replace('disconnect:', '')

        if answer == DisconnectMenuCommand.positive_answer:
            reset_dict = {
                'username': None,
                'host_url': None,
                'auth_method': None,
                'auth.oauth.access_token': None,
                'auth.oauth.access_token_secret': None,
                'auth.basic.password': None,
            }
            status = self.app.db.update_user(scope['telegram_id'], reset_dict)

            if status:
                return self.app.send(
                    bot, update, text='Credentials were successfully reset.')
            else:
                return self.app.send(
                    bot,
                    update,
                    text=
                    'Credentials were not removed from the database, please try again later.'
                )

        else:
            self.app.send(bot,
                          update,
                          text='Resetting credentials was not confirmed')
Exemplo n.º 3
0
    def handler(self, bot, update, *args, **kwargs):
        auth_data = kwargs.get('auth_data')
        try:
            scope = get_query_scope(update)
        except AttributeError:
            telegram_id = update.message.chat_id
            project = kwargs.get('project')
            status = kwargs.get('status')
        else:
            telegram_id = scope['telegram_id']
            project, status = scope['data'].replace('project_status:',
                                                    '').split(':')

        title = 'Issues of "{}" project with the "{}" status'.format(
            project, status)
        raw_items = self.app.jira.get_project_status_issues(
            project, status, auth_data=auth_data)
        key = 'ps_issue:{}:{}:{}'.format(telegram_id, project,
                                         status)  # project_status
        self.app.send(bot, update, title=title, raw_items=raw_items, key=key)
Exemplo n.º 4
0
    def handler(self, bot, update, *args, **kwargs):
        auth_data = kwargs.get('auth_data')

        try:
            scope = get_query_scope(update)
        except AttributeError:
            telegram_id = update.message.chat_id
            filter_name = kwargs.get('filter_name')
            filter_id = kwargs.get('filter_id')
        else:
            telegram_id = scope['telegram_id']
            filter_name, filter_id = scope['data'].replace('filter_p:',
                                                           '').split(':')

        title = 'All tasks which filtered by «{}»:'.format(filter_name)
        raw_items = self.app.jira.get_filter_issues(filter_id=filter_id,
                                                    filter_name=filter_name,
                                                    auth_data=auth_data)
        key = 'filter_p:{}:{}'.format(telegram_id, filter_id)
        self.app.send(bot, update, title=title, raw_items=raw_items, key=key)