Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unicode utf-8 #11

Closed
hmhmat opened this issue Jul 15, 2015 · 18 comments
Closed

unicode utf-8 #11

hmhmat opened this issue Jul 15, 2015 · 18 comments

Comments

@hmhmat
Copy link

hmhmat commented Jul 15, 2015

elif 'what time' in text:
reply('look at the top-right corner of your screen!')

i want bot reply arabic text

like this

reply('اهلا بكم')

@ADTC
Copy link
Contributor

ADTC commented Jul 15, 2015

Have you tried pasting the Arabic text and saving the source file as UTF-8 or Unicode? Works in UTF-8 w/o BOM for me.

You will also need to change 'text': msg.encode('utf-8'), to 'text': msg,. I think you will need to remove the .encode('utf-8') calls in the simsimi URL too if you need to.

@yukuku Why did we use .encode('utf-8')?

@hmhmat
Copy link
Author

hmhmat commented Jul 15, 2015

oh thank .. now its work
i have change 'text': msg.encode('utf-8'), to 'text': msg,

@hmhmat
Copy link
Author

hmhmat commented Jul 15, 2015

who to calls in the simsimi URL ? utf-8

Because now is not working :(
@ADTC

@ADTC
Copy link
Contributor

ADTC commented Jul 15, 2015

What are you asking? Paste your code for the URL.

@hmhmat
Copy link
Author

hmhmat commented Jul 15, 2015

When change msg.encode('utf-8'), to 'text': msg,
simsim It did not work with arabic text

What needs to be changed ? to simsim work with arabic

This code :

if getEnabled(chat_id):
resp1 = json.load(urllib2.urlopen('http://www.simsimi.com/requestChat?lc=en&ft=1.0&req=' + urllib.quote_plus(text.encode('utf-8'))))
back = resp1.get('res')
if not back:
reply('okay...')

@ADTC
Copy link
Contributor

ADTC commented Jul 15, 2015

Update: It seems you don't need to change anything for Simsimi. The original code works already.

Here: (snip)

But Simsimi probably won't respond anything in Arabic anyway. It seems to respond in English only.

Just ensure you replaced the other place correctly: change 'text': msg.encode('utf-8'), to 'text': msg,. (It's at around line 90.)

Do you know Python properly btw?

@hmhmat
Copy link
Author

hmhmat commented Jul 15, 2015

When I write in Arabic .. stops working
@ADTC

@ADTC
Copy link
Contributor

ADTC commented Jul 15, 2015

I pasted your Arabic text as a message to the bot. Simsimi replied some English text like "Hi" and "hello". The bot didn't stop working.

Again, do you know Python properly?

@hmhmat
Copy link
Author

hmhmat commented Jul 15, 2015

Before I change 'text': msg.encode('utf-8') to 'text': msg
It works well , With Arabic texts

but When it was changed to 'text': msg

if I write in Arabic
It stops working

..
I have a knowledge of the language Python 70% Approximately

@ADTC
Copy link
Contributor

ADTC commented Jul 16, 2015

Reply method: remove the encode call
Simsimi URL: keep the encode call

Then everything will work fine. You can test with my bot aaron_bot

@hmhmat
Copy link
Author

hmhmat commented Jul 16, 2015

when i send arabic text to aaron_bot

its stop :(
@ADTC

@ADTC
Copy link
Contributor

ADTC commented Jul 17, 2015

@hmhmat Ha! Thanks for that. I checked my logs and fixed it. Try sending some Arabic text now.

You can get my source code by asking my bot /source

@hmhmat
Copy link
Author

hmhmat commented Jul 17, 2015

i want all file of your bot :)
source not work with me

i need all files
@ADTC

@ADTC
Copy link
Contributor

ADTC commented Jul 18, 2015

@hmhmat The source is provided so you can refer to it and correct your own source. It's not right to blindly put my source in your project and try to run it. My source is already running fine in my bot.

If you really want to run my source, create a new file tokenstore.py in the same folder with the following contents:

def get_token():
    return 'YOUR_BOT_TOKEN_HERE'

I did this so that my token is not publicly retrievable through the /source command.

And also rename the source file name to main.py (move your own version elsewhere). And use all other files from this project. There is no other file that is different from the project.

@hmhmat
Copy link
Author

hmhmat commented Jul 18, 2015

oh thank you @ADTC

How can stop simsmi ?
I want to bot only works commands

@ADTC
Copy link
Contributor

ADTC commented Jul 18, 2015

You cannot stop simsimi. It's an external service. You can just remove the part that sends requests to simsimi.

@ADTC ADTC mentioned this issue Aug 4, 2015
@jtele
Copy link

jtele commented Aug 4, 2015

Thanks you
why when i insert word in arabic it don't work Command
for exampel

when i insert Command
elif 'slam' in text:
reply('سلام')

this line don't work in bot only ?!
bot is work good but this line don't work !!

@ADTC ADTC mentioned this issue Aug 5, 2015
@Prog-Mustafa
Copy link

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

@yukuku yukuku closed this as completed Feb 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants