Exemple #1
0
    def define(self, event, word, dictionary):
        connection = Connection(self.server, self.port)
        dictionary = dictionary is None and '*' or dictionary.lower()
        dictionaries = connection.getdbdescs().keys()

        if dictionary != '*' and dictionary not in dictionaries:
            event.addresponse(
                    u"I'm afraid I don't have a dictionary of that name. I know about: %s",
                    human_join(sorted(dictionaries)))
            return

        definitions = connection.define(dictionary, word.encode('utf-8'))
        if definitions:
            event.addresponse(u', '.join(d.getdefstr() for d in definitions))
        else:
            suggestions = connection.match(dictionary, 'lev', word.encode('utf-8'))
            if suggestions:
                event.addresponse(
                        u"I don't know about %(word)s. Maybe you meant %(suggestions)s?", {
                            'word': word,
                            'suggestions': human_join(
                                self.reduce_suggestions(suggestions),
                                conjunction=u'or'),
                })
            else:
                event.addresponse(u"I don't have a definition for that. Is it even a word?")
Exemple #2
0
    def define(self, event, word, dictionary):
        connection = Connection(self.server, self.port)
        dictionary = dictionary is None and '*' or dictionary.lower()
        dictionaries = connection.getdbdescs().keys()

        if dictionary != '*' and dictionary not in dictionaries:
            event.addresponse(
                    u"I'm afraid I don't have a dictionary of that name. I know about: %s",
                    human_join(sorted(dictionaries)))
            return

        definitions = connection.define(dictionary, word.encode('utf-8'))
        if definitions:
            event.addresponse(u', '.join(d.getdefstr() for d in definitions))
        else:
            suggestions = connection.match(dictionary, 'lev', word.encode('utf-8'))
            if suggestions:
                event.addresponse(
                        u"I don't know about %(word)s. Maybe you meant %(suggestions)s?", {
                            'word': word,
                            'suggestions': human_join(
                                self.reduce_suggestions(suggestions),
                                conjunction=u'or'),
                })
            else:
                event.addresponse(u"I don't have a definition for that. Is it even a word?")
Exemple #3
0
 def handle_dictionary(self, event, dictionary):
     connection = Connection(self.server, self.port)
     dictionaries = connection.getdbdescs()
     dictionary = dictionary.lower()
     if dictionary in dictionaries:
         event.addresponse(unicode(dictionaries[dictionary]))
     else:
         event.addresponse(u"I don't have that dictionary")
Exemple #4
0
 def handle_dictionary(self, event, dictionary):
     connection = Connection(self.server, self.port)
     dictionaries = connection.getdbdescs()
     dictionary = dictionary.lower()
     if dictionary in dictionaries:
         event.addresponse(unicode(dictionaries[dictionary]))
     else:
         event.addresponse(u"I don't have that dictionary")
Exemple #5
0
 def handle_dictionaries(self, event):
     connection = Connection(self.server, self.port)
     dictionaries = connection.getdbdescs()
     event.addresponse(u'My Dictionaries: %s', human_join(sorted(dictionaries.keys())))
Exemple #6
0
 def handle_dictionaries(self, event):
     connection = Connection(self.server, self.port)
     dictionaries = connection.getdbdescs()
     event.addresponse(u'My Dictionaries: %s', human_join(sorted(dictionaries.keys())))