@@ -0,0 +1,1751 @@
+import re%0Afrom collections import deque%0A%0AJPN_RANGES = %5B%0A    (0x3000, 0x303f),%0A    (0x3040, 0x309f),%0A    (0x30a0, 0x30ff),%0A    (0xff00, 0xff21),%0A    (0xff3b, 0xff40),%0A    (0xff5b, 0xffef),%0A    (0x4e00, 0x9faf)%5D%0A%0ASYMBOLS_RANGES = %5B%0A    (0x0, 0x40),%0A    (0x5b, 0x60),%0A    (0x7b, 0x7f)%5D%0A%0AALLOWED = JPN_RANGES + SYMBOLS_RANGES%0A%0AMIN_ALLOWED_PERCENT = 0.5%0A%0APERCENTAGES = %7B%7D%0A%0AACTIVE_CHANNELS = %5B%5D%0A%0A%0Adef is_allowed(char):%0A    for r in ALLOWED:%0A        if r%5B0%5D %3C= ord(char) %3C= r%5B1%5D:%0A            return True%0A    return False%0A%0A%0Adef chars_allowed(string):%0A    a = 0%0A    for c in string:%0A        if is_allowed(c):%0A            a += 1%0A    return a%0A%0A%0Adef is_word(word):%0A    return re.search('%5Ehttps?://', word) is None  # don't consider links spoken language%0A%0A%0Adef overall_percent(nick):%0A    chars = 0%0A    allowed = 0%0A    for t in PERCENTAGES%5Bnick%5D:%0A        chars += t%5B0%5D%0A        allowed += t%5B1%5D%0A    return allowed/chars%0A%0A%0A@yui.event('msgRecv')%0Adef recv(channel, user, msg):%0A    global PERCENTAGES%0A    if channel not in ACTIVE_CHANNELS:%0A        return%0A%0A    key = channel+user.nick%0A    if key not in PERCENTAGES.keys():%0A        PERCENTAGES%5Bkey%5D = deque(%5B(50, 50)%5D * 10, 3)%0A%0A    msg = ''.join(%5Bw for w in msg.split() if is_word(w)%5D)%0A    if len(msg) %3C 1:%0A        return%0A%0A    a = chars_allowed(msg)%0A    PERCENTAGES%5Bkey%5D.appendleft((len(msg), a))%0A%0A    if overall_percent(key) %3C MIN_ALLOWED_PERCENT:%0A        yui.kick(channel, user.nick, '%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%81%A7%E3%81%8Ak')%0A        PERCENTAGES.pop(key)%0A%0A%0A@yui.admin%0A@yui.command('jpnordie')%0Adef switch(channel):%0A    %22%22%22Switch jpnordie on/off for the current channel.%22%22%22%0A    if channel not in ACTIVE_CHANNELS:%0A        ACTIVE_CHANNELS.append(channel)%0A        return '%E9%A0%91%E5%BC%B5%E3%81%A3%E3%81%A6%E3%81%AD o/'%0A    else:%0A        ACTIVE_CHANNELS.remove(channel)%0A        return '%E3%81%BE%E3%81%81%E3%80%81%E3%82%84%E3%82%81%E3%82%88%E3%81%A3%E3%81%8B'%0A

add jpnordie plug