Telegram.Bot icon indicating copy to clipboard operation
Telegram.Bot copied to clipboard

How to send emoji in SendPhotoAsync()

Open A-Programmer opened this issue 10 years ago • 12 comments

Hello. I want to send emoji in SendPhotoAsync() can you help me? please give me this code, i tested anything but i can not send still.

A-Programmer avatar Oct 27 '16 06:10 A-Programmer

Hi, To send Emoji no need that you use SendPhotoAsync(). you can use SendTextMessageAsync() and pass the Unicode of Emoji as message text. Also you can fine the complete Emoji Unicode Table here -> http://apps.timwhitlock.info/emoji/tables/unicode

matiuspico avatar Oct 28 '16 16:10 matiuspico

Thank you but doesn work. this is my code : token.SendTextMessageAsync("MyChanell Id", "U+1F601", true, true, 0, null, ParseMode.Html);

A-Programmer avatar Oct 29 '16 04:10 A-Programmer

Hello,

Search for "C# escape unicode", that should help. It's something like \u1060.

Kind regards, Martijn Verbakel

mhverbakel avatar Oct 29 '16 08:10 mhverbakel

Try to use "\U0001F601" instead of your emoji's code. IntelliSense will remark it to you.

a-a-k avatar Oct 29 '16 08:10 a-a-k

I used your suggestions but dont work! For changing unicodes to emoji i use this function : static string DecodeEncodedNonAsciiCharacters(string value) { return Regex.Replace( value, @"\u(?[a-zA-Z0-9]{4})", m => { return ((char)int.Parse(m.Groups["Value"].Value, NumberStyles.HexNumber)).ToString(); }); } But still no result. Here is a list of emoji codes : http://apps.timwhitlock.info/emoji/tables/unicode

A-Programmer avatar Oct 29 '16 15:10 A-Programmer

It worked, first list is wrong as i see, because second list works fine with this function.

A-Programmer avatar Oct 29 '16 15:10 A-Programmer

Hi, you said second list worked, but i can't find out which list worked? can you send an example? thanks in advance

MTare avatar Mar 14 '17 12:03 MTare

I think he is referring to this list: http://apps.timwhitlock.info/emoji/tables/unicode

Which are then used as "My message \U0001F601" for sending.

token.SendTextMessageAsync("MyChanell Id", "My message \U0001F601", true, true, 0, null, ParseMode.Html);

mhverbakel avatar Mar 14 '17 12:03 mhverbakel

Thanks for your help, but when i send "My message \U0001F601" as input to DecodeEncodedNonAsciiCharacters method, I receive Parsing Error so I've change the method like this:

static string DecodeEncodedNonAsciiCharacters2(string value)
        {
            return Regex.Replace(
            value,
            @"\\u(?<Value>[a-zA-Z0-9]{4})",
            m =>
            {
                return ((char)int.Parse(m.Groups["Value"].Value, NumberStyles.HexNumber )).ToString();
            });
        }

So Second Method worked with that input, Any way Thank you.

MTare avatar Mar 15 '17 05:03 MTare

You can find emoji code point list in https://emojipedia.org/telegram for example for Grinning Face With Smiling Eyes we use code point "U+1F601" this is "0x1F601" now for send text use below code: await Api.SendTextMessageAsync(message.Chat.Id, char.ConvertFromUtf32(0x1F601));

majid23 avatar Jul 25 '17 14:07 majid23

You can just write emojis in a string.

client.SendTextMessageAsync(chatId, "😄");

If you are running Windows 10, enable its touch keyboard and type emojis using that.

poulad avatar Jul 25 '17 16:07 poulad

That's amazing answer it's work for me i want to send emoji on telegram bot using c# and i am visit this page i got my answer thanks a lot..

Coderwill avatar Sep 04 '17 07:09 Coderwill