diff --git a/plugins/MegaHAL/plugin.py b/plugins/MegaHAL/plugin.py
index dd97011b3..cd77849ae 100644
--- a/plugins/MegaHAL/plugin.py
+++ b/plugins/MegaHAL/plugin.py
@@ -33,7 +33,6 @@ import os
import sys
import random
import supybot.conf as conf
-import mh_python as megahal
import supybot.utils as utils
from cStringIO import StringIO
from supybot.commands import *
@@ -41,6 +40,14 @@ import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
+try:
+ import mh_python as megahal
+except ImportError:
+ raise callbacks.Error, 'You need to have MegaHAL installed to use this ' \
+ 'plugin. Download it at ' \
+ '' \
+ 'or with '
+
try:
from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring
@@ -102,6 +109,8 @@ class MegaHAL(callbacks.Plugin):
megahal.learn(msg)
def doPrivmsg(self, irc, msg):
+ if not msg.args[0].startswith('#'): # It is a private message
+ return
message = msg.args[1]
if message.startswith(irc.nick) or re.match('\W.*', message):
@@ -110,8 +119,13 @@ class MegaHAL(callbacks.Plugin):
probability = self.registryValue('answer.probability', msg.args[0])
self._response(message, probability, irc.reply)
-
+
def invalidCommand(self, irc, msg, tokens):
+ if not msg.args[0].startswith('#'): # It is a private message
+ # Actually, we would like to answer, but :
+ # 1) It may be a mistyped identify command (or whatever)
+ # 2) MegaHAL can't reply without learning
+ return
message = msg.args[1]
usedToStartWithNick = False
if message.startswith(message):