This is a telegram bot I made when preparing for OCP 17. It saves questions and answers to them, which can be later asked in a form of quiz. It might be helpful when preparing for some exam.
- Create your bot with BotFather and define 4 commands:
/get_card
,/random_quiz
,/quiz
,/stop
. You should also remember your bot's token received from BotFather, you will need it in step 3 - Compile the project with maven. I've included maven-assembly-plugin, so you can execute
mvn clean compile assembly:single
- To start the bot execute
java -jar quiz.jar [BOT_TOKEN]
command. Insert your token from step 1 instead of [BOT_TOKEN]
- User types a message. a dialog with bot is initiated, where bot asks user to provide details for the future flashcard. When bot gets all the necessary information, the card is saved to the Database
- /get_card command - prints all existing user's flashcards. If user has > 20 cards, the pagination occurs. When user selects one the printed cards, more detailed information is printed about the selected card and a button to delete it
- /random_quiz command - starts quiz with random category (quiz size is limited to 10 flashcards)
- /quiz command - when user selects the category based on a previously saved cards, bot starts quiz (quiz size is limited to 10 flashcards)
- /stop command - oh sh*t button. Stops ongoing quiz (and clears the conversation state)
- /set_quiz_size command to step away from hardcoded size of 10 flashcards per quiz
- /import command to mass import cards as a .csv file
- Making too long question/answer, so that telegram splits it in two messages
- Using buttons from previous conversations may lead to unexpected results