eelcohn / Telegram-API

A gateway between IRC chat channels and Telegram groups, supergroups and channels
MIT License
10 stars 3 forks source link

Problems with some characters #46

Closed TehPeGaSuS closed 5 years ago

TehPeGaSuS commented 6 years ago

When using some chars like ã and similar, i receive this error in partyline: libtelegram::sendMessage: 400 - Bad Request: text must be encoded in UTF-8 can this be fixed?

Thanks

eelcohn commented 6 years ago

Hi, Thanks for pointing this issue out. I've just tested it and can confirm this problem. Most likely it's caused by a (lack of) unicode translation from IRC to Telegram. I'll look into it, but it might take me a couple of days.

eelcohn commented 6 years ago

Okay, fixed it quicker than I thought :)

Could you try out the current devel branch? It should be fixed now.

TehPeGaSuS commented 6 years ago

Sure thing. I'll try it in 30 mins probably. Thanks for the quick fix and response.

TehPeGaSuS commented 6 years ago

Unfortunately the error remains. Words (these are Portuguese) like: não, onça, etc arent relayed to Telegram, but weirdly are relayed from Telegram to IRC.

Can be probably my network? Or even my VPS?

eelcohn commented 6 years ago

Ah too bad; I was hoping for a quick fix :)

Can you give me some more info info?

TehPeGaSuS commented 6 years ago

Yes, the 400 - Bad Request is still there. About the devel branch, I did git checkout devel. And, no, from Telegram to IRC messages are properly displayed.

eelcohn commented 6 years ago

Okay, can you try downloading the devel branch with:

git clone https://github.com/eelcohn/Telegram-API --branch devel

You probably still got the old version of the lib/libunicode.tcl file (you can check the date in the top of this file; it should be 20180305).

TehPeGaSuS commented 6 years ago

Just did that. I've deleted all the files related to your script, cloned the repo as you said, and the error persists. And yes lib/libunicode.tcl has that date.

eelcohn commented 6 years ago

Well, that's weird... Just checking: did you .restart or .rehash your bot?

TehPeGaSuS commented 6 years ago

I've stopped the bot, updated the files and then restarted it (I usually do that to prevent bindings and other stuff to be active). I have no idea if it's my network, the VPS itself or something else that it's causing this troubles (I think I have all the needed libraries to bots work correctly).

eelcohn commented 6 years ago

Still haven't dealt with this bug...

Can you tell me:

I'm gonna try and recreate a virtual computer with the same settings as yours, so I can recreate the problem myself.

eelcohn commented 5 years ago

So, I've finally been able to reproduce your issue in a virtual box! Seems that some Unicode characters often used in the Portugese language were translated to UTF8 twice. I believe this issue is now fixed in the devel branch. Please let me know if it works for you!

TehPeGaSuS commented 5 years ago

Sorry, but I've been pretty busy with real life lately. I'll setup an eggdrop with it tomorrow and I'll give some feedback. Cheers

eelcohn commented 5 years ago

Don't worry about that, real life is more important than online anyways :) It took me up till now to fix this issue due to real life stuff as well :)

TehPeGaSuS commented 5 years ago

Characters seems to be properly relayed now. but I'm facing another issue:

[22:19:22] Tcl error in script for 'timer4':
[22:19:22] can't read "chat_id": no such variable

This is what I get when I access to the API via browser (example):

{"offset":7,"length":8,"type":"mention"}]}},{"update_id":ID_HERE,
"message":{"message_id":14,"from":{"id":ID_HERE,"is_bot":false,"first_name":"PeGaSuS","username":"The_Pegasus","language_code":"pt-br"},"chat":{"id":-CHAT_ID_HERE,"title":"PT_irc","type":"group","all_members_are_administrators":true},"date":1542493290,"text":"test"}}]}

Probably something in the parsing of the JSON output?

NOTE: Messages from IRC are being properly relayed to Telegram, but not from Telegram to IRC

eelcohn commented 5 years ago

Okay, good to hear that the original problem with Portugese characters is now solved!

Unfortunately you probably found another bug :) I've re-checked the Telegram-API.tcl file and found a couple of bad references to the chat_id variable. The current devel branch should have them fixed now.

PS you can reach me at the #telegram-api channel on irc.freenode.net if you want to chat

TehPeGaSuS commented 5 years ago

Well, here's a new error:

can't read "serveraddress": no such variable
can't read "serveraddress": no such variable
    while executing
"::msgcat::mc MSG_TG_WELCOME "$::telegram::tg_chat_title($chatid)" "$::telegram::tg_bot_nickname" "$serveraddress/$channel" "$channel""
    (procedure "::telegram::pollTelegram" line 312)
    invoked from within
"::telegram::pollTelegram"

Once again IRC -> Telegram works but not Telegram -> IRC

eelcohn commented 5 years ago

All these bugs seem to be resolved now. Thanks for your help!

eelcohn commented 5 years ago

In case this issue ever pops up in the future, this is how to reproduce the error: $ LANG=pt_PT.UTF-8 ./eggdrop -nt

Workaround is: $ LANG=en_US.utf8 ./eggdrop -nt