예제 #1
0
파일: chat.py 프로젝트: botasky-lau/mardict
 def __nocmd(self, content):
     if 1 == len(content.split()):
         response = DictCN(content).get_response()
         if response:
             data = response
             reply = '%s [%s]\nfrom: dict.cn\n%s' % \
                     (data['word'], data['pron'], data['define'])
             sender = self.sender
             if 'help' == content:
                 reply += '\nNeed help? Type ":help" for more infomation.'
             else:
                 DictLog.add_record(sender, data['word'], data['define'], data['pron'])
             return reply
     g = GoogleDict(content)
     lan = g.detect_language()
     lan1 = lan
     lan2 = 'zh'
     if ('zh-CN' or 'zh-TW') == lan:
         lan2 = 'en'
     g = GoogleDict(content,lan1,lan2)
     response = g.get_response()
     reply = 'Not Found'
     if response:
         data = response
         reply = '%s\nfrom: google\n%s' % \
                 (data['word'], data['define'])
     return reply
예제 #2
0
파일: chat.py 프로젝트: botasky-lau/mardict
 def __google(self,content):
     if not content:
         return 'You asked nothing'
     g = GoogleDict(content)
     response = g.get_response()
     if response:
         data = response
         reply = '%s\nfrom: google\n%s' % \
                 (data['word'], data['define'])
     else:
         reply = 'Not Found'
     return reply
예제 #3
0
파일: chat.py 프로젝트: botasky-lau/mardict
 def __trans2(self,cmd,content):
     lan = cmd.split('2')
     lan1 = lan[0]
     lan2 = lan[1]
     g  = GoogleDict(content,lan1,lan2)
     response = g.get_response()
     if response:
         data = response
         reply = '%s\nfrom: google\n%s' % \
                 (data['word'], data['define'])
     else:
         reply = 'Not Found'
     return reply