mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-03 16:39:25 +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 sys
|
||||||
import random
|
import random
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import mh_python as megahal
|
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
@ -41,6 +40,14 @@ import supybot.plugins as plugins
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
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:
|
try:
|
||||||
from supybot.i18n import PluginInternationalization
|
from supybot.i18n import PluginInternationalization
|
||||||
from supybot.i18n import internationalizeDocstring
|
from supybot.i18n import internationalizeDocstring
|
||||||
@ -102,6 +109,8 @@ class MegaHAL(callbacks.Plugin):
|
|||||||
megahal.learn(msg)
|
megahal.learn(msg)
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
|
if not msg.args[0].startswith('#'): # It is a private message
|
||||||
|
return
|
||||||
message = msg.args[1]
|
message = msg.args[1]
|
||||||
|
|
||||||
if message.startswith(irc.nick) or re.match('\W.*', message):
|
if message.startswith(irc.nick) or re.match('\W.*', message):
|
||||||
@ -112,6 +121,11 @@ class MegaHAL(callbacks.Plugin):
|
|||||||
self._response(message, probability, irc.reply)
|
self._response(message, probability, irc.reply)
|
||||||
|
|
||||||
def invalidCommand(self, irc, msg, tokens):
|
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]
|
message = msg.args[1]
|
||||||
usedToStartWithNick = False
|
usedToStartWithNick = False
|
||||||
if message.startswith(message):
|
if message.startswith(message):
|
||||||
|
Loading…
Reference in New Issue
Block a user