R
R
Ruda9112017-05-29 18:30:45
Python
Ruda911, 2017-05-29 18:30:45

How to write a simple Python test for Telegramm?

I'm trying to write a bot in telegram. I want to write a regular test. What would be 20 questions. The bot took 10 or 15 randomly. But it turns out only to write questions sequentially. Tell me the literature for writing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aristarkh Deryapa, 2017-06-14
@isisTance

So choose a random question. And better in the oop style (this is an example and only):

import random as rand
class qustion:
    def __init__(self, text):
        self.asked = False
        telegramAPI.sendmessage(text)
        answer = telegramAPI.user.message()

def start_quiz():
    asked_q = 0
    while asked_q < 2:
        numb = rand.randint(1, 2)

        if numb == 1 and not q1.asked:
            q1 = qustion("Text 1")\
            q1.asked()

        if numb == 2 and not q2.asked:
            q2 = qustion("Text 2")\
            q2.asked()

And then stamp out questions along the assembly line. And if I showed an example of how it works, I didn’t work with the API, so I can’t give a clear one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question