What kind of event should trigger the functionality?
A user presses an InlineKeyboardButton within the bot itself
What kind of chat is the functionality supposed to work in?
The button is on a message that is from a bot to the user. (i.e inside chat with a bot. NOT in a group/channel)
How do you want your bot to react?
I wish to read the text of the message using text = str(update['callback_query']['message']['text'])
I then wish to edit that message using query.edit_message_text(text=text, reply_markup = keyboard)
What is the problem?
In step 1, that 'text' field is completely missing in the 'Update' dictionary.
As a result, the 'edit_message' in step 2 dont work and throw "Message to edit not found telegram"
The above behavior occurs for posts about 48hours from today. Meaning the inlinebutton works normally first, then after ____ period of time passed, the error described above is observed.
What is my hypothesis?
Telegram side deletes that information and dont allow me to call it after ____ period in time.
There is an answerCallbackQuery that allows you to create an alert reaction on user pressing InlineKeyboardButton. Is there any possibility to create simillar alert but with the input field to prompt user to enter some text and send it to bot?
Nope, you can't do that with answerCallbackQuery, at least for now.
Possible workarounds - send a new InlineKeyboard with desired options, or mutate an existing one using editMessageReplyMarkup.
I am creating a telegram bot and using sendMessage method to send the messages.
it is easy to mention user using #username, But how to mention user when they don't have username?
If using the telegram app/web, we can mentioned the user by #integer_id (name), and telegram app/web will convert it into clickable text. integer_id will be generated automatically when we select the user, after typing #.
another background:
I am trying to use forceReply and I want to target user, if they have username, I can easily target them, by mentioning them on the text on sendMessage method.
the bot I am creating is a "quiz" like bot. where each player need to take turn, and the bot is sending them the question, each msg from bot will target different player.
NOTE: I am not disabling the Privacy Mode, I don't want telegram bombing my server with msg I don't need. it was overloading my cheap nasty server. so, disabling it not an option.
I am open for other solution, where the bot can listen to selected player.
thanks.
UPDATE 21/10:
I've spoke to BotSupport for telegram, they said, for now Bots can't mention user without username.
so in my case, I still keep using forceReply, and also, gave a short msg to user which doesn't have username to set it up, so they can get the benefit from forceReply function.
According to official documentation it is possible to mention user by its numerical id with markup:
[inline mention of a user](tg://user?id=123456789)
According to this link :
it is possible to mention user by its numerical id with markup:
Markdown style
To use this mode, pass Markdown in the parse_mode field
when using sendMessage. Use the following syntax in your message:
[inline mention of a user](tg://user?id=123456789)
and you can also use HTML style :
HTML style
To use this mode, pass HTML in the parse_mode field when using sendMessage. The following tags are currently supported:
inline mention of a user
Try this:
#bot.message_handler(func=lambda message: True)
def echo_message(message):
cid = message.chat.id
message_text = message.text
user_id = message.from_user.id
user_name = message.from_user.first_name
mention = "["+user_name+"](tg://user?id="+str(user_id)+")"
bot_msg = f"Hi, {mention}"
if message_text.lower() == "hi":
bot.send_message(cid, bot_msg, parse_mode="Markdown")
For python-telegram-bot you can do the following:
user_id = update.message.from_user['id']
user_name = update.message.from_user['username']
mention = "["+user_name+"](tg://user?id="+str(user_id)+")"
response = f"Hi, {mention}"
context.bot.sendMessage(chat_id=update.message.chat_id,text=response,parse_mode="Markdown")
No, this restriction is related to Telegram's privacy policy and prevention of abuse.
It is possible to mention a user when sending messages (BOT API), but that is not what you need:
[inline mention of a user](tg://user?id=<user_id>)
Links tg://user?id= can be used to mention a user by their id without using a username. Please note:
These links will work only if they are used inside an inline link. For example, they will not work, when used in an inline keyboard button or in a message text.
These mentions are only guaranteed to work if the user has contacted the bot in the past, has sent a callback query to the bot via inline button or is a member in the group where he was mentioned.
https://core.telegram.org/bots/api#markdown-style
you need to link to the text: "tg://user?id=" and id
user_id = 123456XX # id of the user to mention
chat_id = 123456XXX # chat id where to mention
user_name = name of user
await bot.send_message(chat_id, f"<a href='tg://user?id={user_id}'>{user_name}</a>", "HTML")
here is an example:
#dp.message_handler()
async def mention(msg: types.Message):
await msg.answer(f"<a href='tg://user?id={msg.from_user.id}'>{msg.from_user.full_name}</a>", "HTML")
Bots are able to tag users by their ID, they just can't do this using the official HTTP Bot API.
Update: Not necessairy anymore, since Telegram added native Support for this.
If you log into your bots account with MadelineProto (PHP) you can use this 'link' to mention someone by it's ID with parse_mode set to markdown
[Daniil Gentili](mention:#danogentili)
I have a application window with two text fields (no access to the application code, so cant change anything). User scans a barcode in the fields, the action "enter press" is programmed in the scanner and cannot be changed. I need to validate the fields before enter is pressed, I can validate the first field but the issue is I need to validate the second field before enter is press(which is through the scanner). Is there a way this can be achieved using AutoIT? I hope the question make sense.
Use the "AutoIt v2 Window Info" tool (Au3Info.exe) to identify the two edit controls. On the "Control" tab you find the "Advanced Mode", which will show data like "[CLASS:Edit;INSTANCE:2]". Now use this information to read the data of the control:
$Text1 = ControlGetText('window title', '', '[CLASS:Edit; INSTANCE:1]')
$Text2 = ControlGetText('window title', '', '[CLASS:Edit; INSTANCE:2]')
See the example here: http://www.autoitscript.com/autoit3/docs/functions/ControlGetText.htm
most barcode scanners can be programmed to not send the terminator (enter) usually by scanning a couple special barcodes in the users manual
I program scanners with special terminators so our program can tell the input was from a scanner and not key presses
My question is quite simple (i think) but cannot find the right module for that.
I'm working on a small classified website in which i have a bunch of nodes. I display them using views.
I'd like for any (authenticated with role) user of the website to be able to click on a kind of button like "I'm interested" which will trigger an event doing various actions like 'changing one cck field' on that content-type and also send an e-mail to the author of the classified.
Pretty straight forward but no clue on where to start, which module should i use ?
For this, you can use the Flag Module and Rules Module
In your view, you can create a relationship to flags to allow the use of other 'fields'.
Using Rules, create a new rule that is triggered when a node is flagged (or unflagged). Rules allows you to do both: changing a CCK field and sending out emails when an event occurs.
Walk-through:
Install and enable the Flag Module and Rules Module
Create a new flag at "admin/build/flags"
Edit/Create you classified view, add a relationship to Flags: Node Flag and choose > the name of the flag you just created.
Under "fields" add Flags: Flag link and configure as you like
Add a new rule at "admin/rules/trigger/add" for the event A node has been flagged,
under "FLAG NAME"
Add action to perform of Populate a field under the heading CCK
Add action to perform of Send a mail to a user under the heading System
and configure your desired settings.
Then when a user clicks the "interested" flag a field will be populated and email sent.