mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
MegaHAL: Don't learn private messages.
Issue S-fr#3
This commit is contained in:
parent
7e58815530
commit
cd025be24a
@ -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 ' \
|
||||
'<http://megahal.alioth.debian.org/>' \
|
||||
'or with <apt-get install megahal>'
|
||||
|
||||
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):
|
||||
@ -112,6 +121,11 @@ class MegaHAL(callbacks.Plugin):
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user