parse_moin_bye(): limit matching to full words

This commit is contained in:
urlbot
2015-06-17 11:17:29 +02:00
parent 328aecfbb0
commit b7f0087e0d

View File

@@ -134,12 +134,22 @@ def parse_moin_bye(**args):
for direction in [moin, bye]:
for d in direction:
if d.lower() in args['data'].lower() and len(args['data'].split()) < 3:
logger('plugin', 'sent %s reply' % (
'moin' if direction is moin else 'bye'
words = re.split(r'\W+', args['data'])
# assumption: longer sentences are not greetings
if 3 < len(args['data'].split()):
continue
for w in words:
if d.lower() == w.lower():
logger('plugin', 'sent %s reply for %s' % (
'moin' if direction is moin else 'bye', w
))
return {
'msg': '''%s, %s''' % (random.choice(direction), args['reply_user'])
'msg': '''%s, %s''' % (
random.choice(direction),
args['reply_user']
)
}
@pluginfunction('latex', r'reacts on \LaTeX', ptypes_PARSE)