HappySecretSantaBot - Telegram bot for the game "Secret Santa"

    Hello hrobrozhiteli!

    A bit of history

    When I was still a schoolboy, I opened with Habr periods, and one of the articles that I remembered at that time was the Club of anonymous Santa Clauses 2013 - 2014 . At that time, it seemed to me one of the coolest ideas to organize such actions, where you can be in the role of Santa Claus for a complete stranger, and at the same time receive a gift from the same stranger. After this habropost, I learned that such a thing exists in general, which in principle gave further impetus to the writing of this bot.

    Last New Year's Day, I also had such an action at work, where every person in the room had a random person, and you had to give a gift to the person who fell out to you, and this person, in turn, also gives another person. In the end, all remain with gifts and satisfied.

    In the last year I had a hobby to create bots on the VK platform, even simply without releasing them into the world, but just for myself. I started to create various bots for myself, I had a public of my city, which at that time I attracted a lot of people with the help of a bot. I liked that people could spend a lot of time poking into the bot's functionality, and got pleasure from it, which motivated me to constantly look for new ideas on how to please people, then several customers addressed me to write bots for their publics, and everyone was happy.

    So, I wanted to go with VK (what is there to catch actually already?)in Telegram, since I heard that this is an excellent platform for bots. And of course, in order to make a bot, you need an idea. The idea came almost immediately, because the New Year is coming, and the bot in the form of the “Secret Santa” is not a common thing in Telegram, and the desire to write it was a long time ago. Just in the form of sites, as for me, it does not make sense to do this, because there are a lot of such sites. And in the period of some time I sat down to read the Telegram BOT API documentation (because I was completely unfamiliar, this is my first project on this platform), I looked for Open Source bots on Github, I watched people develop, sat down for a while, wrote as i want it to look like. Actually further, I want to introduce you to my creation.

    What it looks like now

    A user is greeted by a welcome message before the game, which explains that the game has two modes: single and command.

    Single under himself provides that the user finds a completely random Santa (within his country). The user presses the button that he wants to find a completely random Santa, the system registers it, and every hour goes and combines in pairs those who do not have it. Within an hour (if, of course, at this moment there are users from your country also without Santa), the user will receive a message with information about his recipient, and also about the fact that Santa is found.

    Commandgives users the right to merge into rooms. This is well suited to those who, for example, in offices, or in a large team of friends want to give each other gifts. One person creates a room in the bot, the bot gives the room number to the leader of the room where he can invite other people. People enter the room of this room and fall into it. To start the game, there should be an even number of users in the room, and the leader of the room should click / play. After that, the bot will mix all users and everyone will get its Santa, each person in the room will receive a personal message from Bot, with the data where to deliver the gift. Leaving the room is impossible if the user has already got Santa. However, the room can be left if the user has not yet received Santa. The leader (creator) of a room cannot leave the room if there is at least someone besides him.

    After the start of the game, the bot asks the user for information about his country, city, address, full name, wishlist (each user can write a list of desires that Santa can listen to). Further, the person either joins the room, either creates it, or finds the accidental Santa outside the rooms. After you send a gift to the address of your recipient, you must click / sent (the bot will notify the recipient that you sent the parcel, and it will not be long to wait). When the package arrives, you can hit / delivered (all these commands are in the commands of the bot in navigation), and your Santa will receive a notification, with "plus karma and respect."

    The bot once a month also reminds those who have not yet sent a gift, that the New Year is coming soon, and there is no need to be a bad Santa, you need to hurry.

    Below I leave a few screenshots of the bot.

    A couple of bot screens

    What is implemented

    I will not dwell on the technical part at all (perhaps the topic of another post), just for those interested I will name, with the help of what I developed.

    YAP : PHP 7
    DBMS : MySQL
    SDK : Telegram BOT PHP SDK

    Anyone interested in the bot can be found in Telegram as @HappySecretSantaBot

    All the great December, write bots (this is cool) and Happy New Year!

    Also popular now: