Пример #1
0
    async def answer_question(self, story, answer):
        story_id = story['id']

        question_id = dget(story,
                           'story_questions.0.question_sticker.question_id')
        if not question_id:
            return True

        q_type = dget(story,
                      'story_questions.0.question_sticker.question_type')
        if q_type != 'text':
            return True

        url = f'https://i.instagram.com/api/v1/media/{story_id}/{question_id}/story_question_response/'

        data = self.api.json_data({
            "_csrftoken":
            self.api.token,
            "client_context":
            self.api.generate_UUID(True),
            "mutation_token":
            self.api.generate_UUID(True),
            "_uuid":
            self.api.uuid,
            "type":
            "text",
            "_uid":
            self.api.user_id,
            'response':
            answer,
        })
        data = self.api.generate_signature(data)

        return await wrap(lambda: self.api.session.post(url, data))()
Пример #2
0
    async def quiz_story(self, story, variant=None):

        quiz_id = dget(story, 'story_quizs.0.quiz_sticker.quiz_id')
        if not quiz_id:
            return

        tallies = dget(story, 'story_quizs.0.quiz_sticker.tallies')
        if not isinstance(tallies, list):
            return

        correct = dget(story, 'story_quizs.0.quiz_sticker.correct_answer')

        variant = correct if variant is None else correct

        story_id = story['pk']

        url = f'https://i.instagram.com/api/v1/media/{story_id}/{quiz_id}/story_quiz_answer/'

        data = {
            "_csrftoken": self.api.token,
            "_uuid": self.api.uuid,
            'answer': variant,
        }
        # data = self.api.generate_signature(data)

        return await wrap(lambda: self.api.session.post(url, data))()
Пример #3
0
    async def apply_countdown(self, story):
        countdown_id = dget(
            story, 'story_countdowns.0.countdown_sticker.countdown_id')
        enabled = dget(
            story, 'story_countdowns.0.countdown_sticker.following_enabled')

        if not enabled:
            return True

        url = f'https://i.instagram.com/api/v1/media/{countdown_id}/follow_story_countdown/'

        data = self.api.json_data({})
        data = self.api.generate_signature(data)
        return await wrap(lambda: self.api.session.post(url, data))()
Пример #4
0
    async def vote_slider(self, story, variant=None):
        slider_id = dget(story, 'story_sliders.0.slider_sticker.slider_id')
        if not slider_id and dget(
                story, 'story_sliders.0.slider_sticker.viewer_can_vote'):
            return

        story_id = story['id']
        url = f'https://i.instagram.com/api/v1/media/{story_id}/{slider_id}/story_slider_vote/'

        variant = 0.8 + randint(0, 200) / 1000 if variant is None else variant

        data = self.api.json_data({
            "_csrftoken": self.api.token,
            "_uuid": self.api.uuid,
            "_uid": self.api.user_id,
            'vote': str(variant),
            'radio_type': 'wifi-none'
        })
        data = self.api.generate_signature(data)

        return await wrap(lambda: self.api.session.post(url, data))()