equal
deleted
inserted
replaced
|
1 #$ neutron_plugin 01 |
|
2 |
|
3 import DICT |
|
4 import urllib |
|
5 |
|
6 def handler_dict_define(type, source, parameters): |
|
7 dc = DICT.DictConnection('dict.org') |
|
8 try: |
|
9 results = dc.get_definition(parameters.strip()) |
|
10 if len(results): |
|
11 #reply = string.join(results[0], '\n') |
|
12 reply = 'http://www.dict.org/bin/Dict?Form=Dict1&Query=' + urllib.quote(parameters) + '&Strategy=*&Database=*' |
|
13 for result in results[:3]: |
|
14 reply += '\n\n' + string.join(result[:8], '\n')[:500][4:] |
|
15 if len(result) > 8: |
|
16 reply += ' . . .' |
|
17 reply = reply.replace('\n\n\n', '\n\n') |
|
18 else: |
|
19 reply = 'No Results' |
|
20 except: |
|
21 raise |
|
22 reply = 'Error' |
|
23 smsg(type, source, reply.rstrip()) |
|
24 |
|
25 register_command_handler(handler_dict_define, 'dict', 0, 'Defines a word using the DICT protocol.', 'dict <word>', ['dict jabber']) |