yukuku / telebot

Telegram Bot starter kit. Very easy to install with Google App Engine.
Apache License 2.0
689 stars 234 forks source link

Simsimi #36

Closed tugapower0 closed 8 years ago

tugapower0 commented 8 years ago

Simsimi its no more working. Any workround ?

pualien commented 8 years ago

You have to use a trial API key (here) and make requests to simsimi. If you have any troubles ask again.

tugapower0 commented 8 years ago

can you show what part of code must change ?

pualien commented 8 years ago

You could for example add this library to your lib folder. Then add this code to your else statement:

else:
            from lib.simsimi import SimSimi
            from lib.language_codes import LC_ITALIANO
            from lib.simsimi import SimSimiException

            back = ''
            simSimi = SimSimi(conversation_language=LC_ITALIANO,
                              conversation_key='YOUR_API_KEY')

            try:
                from unicodedata import normalize
                text = normalize('NFKD', text).encode('ASCII', 'ignore')
                response = simSimi.getConversation(text)
                if not response['response']:
                    reply('You exceeded simsimi api daily limit!')
                back = response['response']
            except SimSimiException as e:
                    print e
            if not back:
                reply('Something went wrong..')
            elif 'I HAVE NO RESPONSE' in back:
                reply('you said something with no meaning')
            else:
                reply(back)