summaryrefslogtreecommitdiffstats
path: root/bots/eng-mal-bot.py
diff options
context:
space:
mode:
authorSanthosh Thottingal <santhosh.thottingal@gmail.com>2009-03-13 16:44:38 +0530
committerSanthosh Thottingal <santhosh.thottingal@gmail.com>2009-03-13 16:44:38 +0530
commit2cea4faae67f7ec777bd781b0f77bac0abc527a9 (patch)
tree712d3ffd0e42c102927364b9df4dbddb561cbec7 /bots/eng-mal-bot.py
parent5c86e6a6743662d5b2b23cba0d35272c2448b860 (diff)
downloadRachana.git-2cea4faae67f7ec777bd781b0f77bac0abc527a9.tar.gz
Rachana.git-2cea4faae67f7ec777bd781b0f77bac0abc527a9.tar.xz
Rachana.git-2cea4faae67f7ec777bd781b0f77bac0abc527a9.zip
Fix for displaying no definition found by Ragsagar
Diffstat (limited to 'bots/eng-mal-bot.py')
-rwxr-xr-xbots/eng-mal-bot.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/bots/eng-mal-bot.py b/bots/eng-mal-bot.py
index 36e7fe0..f6a5644 100755
--- a/bots/eng-mal-bot.py
+++ b/bots/eng-mal-bot.py
@@ -21,10 +21,11 @@
import xmpp
from xmpp.protocol import *
import os
+import commands
options = {
'JID': 'eng.mal.dict@gmail.com',
- 'Password': 'mail santhosh if you need password for this',
+ 'Password': '*******',
}
class ConnectionError: pass
@@ -70,10 +71,13 @@ class Bot:
if(mess_node.getBody()):
command = "dict --database dict-en-ml '" + mess_node.getBody() +"'"
- stdin, stdout = os.popen2(command)
- # ... put some content into reply node
- conn.send( xmpp.Message( mess_node.getFrom() ,stdout.read()))
- stdout.close()
+ output = commands.getoutput(command)
+ if output.find('No definitions found') is not -1:
+ print "No definitions found"
+ conn.send( xmpp.Message( mess_node.getFrom(),'No Definitions Found'))
+ else :
+ print "definition found"
+ conn.send( xmpp.Message( mess_node.getFrom() ,output))
raise NodeProcessed # This stanza is fully processed