why the telegram bot function works 50 percent - python

I wrote a python function for a telegram bot that generates a random captcha that the user must solve, and then checks if the information he entered matches it. If the user enters the correct captcha, the bot welcomes him and lets him into the group. If the user does not enter the correct captcha within 60 seconds, the bot will kick him out of the group. Additionally, the bot will delete all captcha-related messages (bot and user messages, welcome message after 30 seconds)
The problem is that the bot does not kick the user after 60 seconds and does not delete its own message with a suggestion to enter a captcha, everything else works. Help fix this
I have already tried various options for functions, I tried to rewrite them, but nothing happens, by the way, I wrote functions using the aiogram library

Related

how to make two people communicate through the bot

I can’t figure out how to make two people communicate through the bot? That is, user1 >message> bot>message>user2 It turns out that the bot acts as an intermediary, passing messages from one user to another
I was thinking of making a database with a user ID, and if a person clicks on the "find a friend" button, the status of his ID = True And if 2 people with the True status, then they can communicate with each other, but there are no further thoughts at all .... Please help((
Remember, the Telegram bot will never be able to write to the user, if he himself did not activate this bot before.
So. Your idea can be implemented as follows. The user enters the bot and is offered a choice (two buttons). The first button is "connect with a random user", and the second is "connect by id".
The first option: you accept a message from that user and duplicate it to another (and vice versa).
The second option: if the user enters the correct id of another user, he receives a notification about a successful connection, and then everything is the same as in the first option. If the id is incorrect - an error message.
For navigation I would use InlineKeyboard (or alternatively ReplyKeyboard). It turns out that the bot will be an intermediary between users.
Disadvantages for users: you (an outsider) will be able to save all correspondence and view them. View complete information about the user's account.
Benefits for users: They will be completely anonymous to each other.
I could say more about this, but I don't quite understand the point of creating a bot for such things

How to make user hyperlink in python telegram bot?

Stack overflow!
I'm using telebot module for my telegram bot (from telebot import types).
I want to send messages to telegram users.
In this messages I want to paste a link to another telegram users.
My code is:
linked_user = '[username](tg://user?id=999999999)'
bot.send_message(
admin_chat_id, f'{linked_user}',
parse_mode='MarkdownV2',
disable_web_page_preview=True)
I expect that admin will receive a message with username in it.
And if admin will click on the text, he will be redirected to the linked_user's profile...
The problem is:
It's not always a hyperlinked text. It can be a plain text...
With some user's chat.id's it works well, with other - don't!
I tried to make decisions from the fact, than not every telegram user have 9-digit chat.id - but it's not the reason too...
So I want to make hyperlink for EVERY user... don't know how to do that, so please help me!)
Some Users have specific privacy settings. So even though you can pm them, you cant "publish" their usernames so anyone else can Contact them. So you are not doing anything wrong.

How to don't send the bot's username in python telegram bot switch_inline_query

I am making the inviting friend into the bot.
InlineKeyboardButton('👬 Invite Friend', switch_inline_query = 'https://t.me/xxxx?start=friend-' + str(user['id']))
After the click, the button and I choose the chat on my contacts.
But on a friend's chat, the bot's username is inserted. I want to send only the link.
I want to remove this.
or I want to make like this.
There is no way to remove the username of the bot from the message itself.
Altough many bots use a workaround where you are prompted with a username and a special identifier which allows the bot to prompt the InlineQuery mode and show up a button which can send any text you want
(I've found this simple bot that does this too, you can try it here)
Here's also an example found on the official python_telegram_bot repo

Telegram bot location

Is it possible to find out a person location each time when user sends a message to bot. Or how can I find out the user's location? I would like to do this without sending the key position. Thanks
No you can't get user locations without their permission unless you use request_location in your keyboard, then it will show a message and asks user for the permission.
https://core.telegram.org/bots/api/#keyboardbutton

Online status for Jabber bot

I use xmpppy library for creating my bot. I run the bot and it works correctly, but when I enter to MirandaIM with other user account(not bot account) for testing it I see that its status is offline. Although I can send and receive messages. How can I send to all bot's 'friends' that it is online?
To manage presence with your bot you need to:
Make sure the roster is properly defined. For example, you bot contact and your user should be each other in their respective contact list.
Once it is done, send a presence packet when you login and you should see the presence properly broadcasted.
Reference document is: http://xmpp.org/rfcs/rfc3921.html#int

Categories

Resources