PureTelegram (framework for using the Telegram API)
Re: PureTelegram (framework for using the Telegram API)
I think It's not possible.
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
The user needs to contact the bot and open a private chat with it.pozvonok wrote: Fri Sep 30, 2022 9:07 am Hello. Thanks for your great work.
Can a bot use this API to communicate with the user in a dialogue?
without public chat.
I didn't find how to do it.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
How to use the @username to send message to it in a private chat?
I can't use the "@username" for ChatID get error 400, chat not found, the only way is to use the numeric ID, but that way I must find the number with another bot.
What I'm doing wrong?
I can't use the "@username" for ChatID get error 400, chat not found, the only way is to use the numeric ID, but that way I must find the number with another bot.
What I'm doing wrong?
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
When you say "private chat", do you mean a private group? If you mean a private one-to-one chat with a person, you can't send messages to such a chat using the API.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
I mean an open chat with my bot.
I can send messages if on my #UserID I use the number, but I can't use the username its self (ex: @myname).
In other words... How to send messages to an user name (not number id)?
Sorry my poor english
I can send messages if on my #UserID I use the number, but I can't use the username its self (ex: @myname).
In other words... How to send messages to an user name (not number id)?
Sorry my poor english

Last edited by Caronte3D on Fri Oct 21, 2022 7:26 pm, edited 1 time in total.
Re: PureTelegram (framework for using the Telegram API)
This works:
This doesn't work:
From your Help:
"In PureTelegram, every command requires an input variable "chat_id". This can be either the chat's ID number or @username, but never its title."
But I can't use the @username, because I get every time an error:
ERROR: *{"ok":false,"error_code":400,"description":"Bad Request: chat not found"}*
Code: Select all
#ChatID = "123456789"
#BotAPIToken = "9999999999:AAE2ZZ1Vq6pbruVnwIxYbo3qrgE58pyaKX8"
Define txt.s = "SOME TEXT"
Telegram_PostText(#BotAPIToken,#ChatID,txt)
Code: Select all
#ChatID = "@myName"
#BotAPIToken = "9999999999:AAE2ZZ1Vq6pbruVnwIxYbo3qrgE58pyaKX8"
Define txt.s = "SOME TEXT"
Telegram_PostText(#BotAPIToken,#ChatID,txt)
"In PureTelegram, every command requires an input variable "chat_id". This can be either the chat's ID number or @username, but never its title."
But I can't use the @username, because I get every time an error:
ERROR: *{"ok":false,"error_code":400,"description":"Bad Request: chat not found"}*
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
What happens if you omit the @ symbol?
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
I get the same error
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
I've just realised, only public chats can have a @username. I think you must have made a mistake - the private chat you're targeting doesn't have a @username.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
I don't understand
I only want a way to send and receive messages from an user to the bot and viceversa, I do it already with the userID, but no with the @username.
Everything works well If I use de userID number, but in that case I must find that number using another telegram bot: @userinfobot

I only want a way to send and receive messages from an user to the bot and viceversa, I do it already with the userID, but no with the @username.
Everything works well If I use de userID number, but in that case I must find that number using another telegram bot: @userinfobot
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
Right, so it's not a group or channel, it's a private chat between a user and the bot. A private chat NEVER has a @username, and you can't send a message to a person by using their personal @username either. You need the numerical ID of the private chat between the user and your bot.
When the bot receives a message, analyse the message and get its chat ID and use that.
When the bot receives a message, analyse the message and get its chat ID and use that.
Code: Select all
Procedure.b HandleMessagePosted(*u.TG_Update)
With *u
If \message\text = "Hello bot."
txt.s = "Hello user."
Telegram_PostText(#BotAPIToken,Str(\message\chat\id),txt)
EndIf
EndWith
EndProcedure
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
Oh! Ok, ok... I see now 
Thanks for your help

Thanks for your help

Re: PureTelegram (framework for using the Telegram API)
Hi!
If I try to replace an image to a message in a group, the app closes because memory error.
I was expect a "false" value on return in case the message fails to update, so I could send a new message instead.
EDIT: I think doing that without the caption string runs ok
If I try to replace an image to a message in a group, the app closes because memory error.
I was expect a "false" value on return in case the message fails to update, so I could send a new message instead.
EDIT: I think doing that without the caption string runs ok

Code: Select all
If Not Telegram_ReplaceMessageImageWithPBImage(#BotAPIToken,#ChatID,lastMsgID,image,"caption")
ultimoMsgID=Telegram_PostPBImage(#BotAPIToken,#ChatID,image,"caption")
EndIf
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
Have you included UsePNGImageEncoder() and UseJPEGImageEncoder() ?
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
Yes!Seymour Clufley wrote: Thu Jan 05, 2023 6:46 am Have you included UsePNGImageEncoder() and UseJPEGImageEncoder() ?