# coding=utf-8

import random
import re

phrases = [
    ['hi', 'hello'],
    ['yo', 'sup'],
    ['hallo', 'tag', 'moin'],
    ['こんにちは', 'こんちわ'],
    ['よ', 'やぁ', 'おっす']
]


def getRandomExcept(arr, ex):
    if not ex in arr:
        return random.choice(arr)
    idx = arr.index(ex)
    arrEx = arr[:idx] + arr[idx + 1:]
    return random.choice(arrEx)


@yui.event('msgRecv')
def greetings(msg, channel):
    global phrases

    answer = None
    lower = msg.lower()
    lower = re.sub('[!?\. ]', '', lower)
    for s in phrases:
        if lower in s:
            yui.send_msg(channel, getRandomExcept(s, lower))

@@ -34,16 +34,24 @@
 ort re%0A%0A
+builtin_
 phrases 
@@ -173,16 +173,79 @@
 %E3%81%A3%E3%81%99'%5D%0A%5D%0A%0A
+phrases = yui.config_val(%22greetings%22, default=builtin_phrases)%0A
 %0Adef get

make greetings configurable in json