Example #1
0
def act_bloodmoon(ircbot, conf, conn, event, data):
    global bloodmoon_flag
    global bloodmoon_dryrun

    if bloodmoon_flag:
        rnd = random.randint(1, 6)

        if rnd  == 1:
            _bloodmoon_kick(ircbot, conf, conn, event, data['source'], data['target'], data['message'])
        elif rnd  == 2:
            _bloodmoon_nooper(ircbot, conf, conn, event, data['source'], data['target'], data['message'])
        elif rnd == 3:
            msg = config.get('command:bloodmoon', 'msg_type1')
            conn.notice(data['target'], msg) 
        elif rnd == 4:
            msg = config.get('command:bloodmoon', 'msg_type2')
            conn.notice(data['target'], msg) 
        elif rnd == 5:
            msg = config.get('command:bloodmoon', 'msg_type3')
            conn.notice(data['target'], msg) 
        else:
            msg = config.get('command:bloodmoon', 'msg_type4')
            conn.notice(data['target'], msg) 

        return {}
    else:
        return None
Example #2
0
def cmd_bloodmoon(ircbot, conn, event, data, *args):
    ''' [killer]
    Rise The Blood Moon in typical duration...
    what's Blood Moon? please see http://terraria.arcenserv.info/wiki/Blood_Moon
    '''
    def clear_flag():  
        global bloodmoon_flag  
        bloodmoon_flag = False  
        cmd_msg_stop = config.get('command:bloodmoon', 'msg_stop')
        conn.notice(data['target'], cmd_msg_stop) 
        logging.info('[bloodmoon] stop.')

    global bloodmoon_flag  
    global bloodmoon_dryrun

    if not bloodmoon_flag:  
        bloodmoon_flag = True
        cmd_msg_start = config.get('command:bloodmoon', 'msg_start')
        duration = config.getint('command:bloodmoon', 'duration_sec')
        conn.notice(data['target'], cmd_msg_start) 
        ircbot.ircobj.execute_delayed(duration, clear_flag)
        logging.info('[bloodmoon] start duration:%d sec.', duration)

        if args[0] == "killer":
            bloodmoon_dryrun = False
            conn.notice(data['target'], "KILLER MODE.") 
            logging.info('[bloodmoon] KILLER MODE.')
        else:
            bloodmoon_dryrun = True

    else:
        cmd_msg = config.get('command:bloodmoon', 'msg_type0')
        conn.notice(data['target'], cmd_msg) 

    return {} 
Example #3
0
def act_totsuzen(ircbot, conf, conn, event, data):
    ''' <word>
    TOTSUZEN NO DEAD
    '''
    max_wchar_len = int(config.get('plugin:totsuzen', 'max_wcharlen')) or 15
    errmsg_overrun = config.get('plugin:totsuzen', 'errmsg_overrun') or 'to long ...'

    wcharlen = count_widechars(data['message'])
    if  wcharlen > max_wchar_len:
        logging.info('[totsuzen] message wide-char length too long (msg:%d, max:%d)',wcharlen ,max_wchar_len )
        conn.notice(data['target'], errmsg_overrun)
        return None

    totsuzen_ctx = gen_totsuzen_aa(data['message'])
    # これはこれで面白いから残しとく
    #totsuzen_ctx = gen_totsuzen_aa(u" ".join(data['message']))
    for i in totsuzen_ctx:
        conn.notice(data['target'], totsuzen_ctx[i])
Example #4
0
def _bloodmoon_nooper(ircbot, conf, conn, event, source, target, msg):
    if not target or not source:
        logging.error('[bloodmoon] cannot exec with "target:%s", "source:%s"', target, source)
        return None

    logging.info('[bloodmoon] disoper "source:%s", "target:%s"', target, source)
    msg = config.get('command:bloodmoon', 'msg_nooper')
    conn.notice(target, msg)
    if not bloodmoon_dryrun:
        conn.mode(target, '-o %s' % source)

    return {}
Example #5
0
def _bloodmoon_kick(ircbot, conf, conn, event, source, target, msg):
    if not target or not source:
        logging.error('[bloodmoon] cannot exec with "target:%s", "source:%s"', target, source)
        return None

    logging.info('[bloodmoon] kick "source:%s", "target:%s"', target, source)
    msg  = config.get('command:bloodmoon', 'msg_kick')
    conn.notice(target, msg)
    if not bloodmoon_dryrun:
        conn.kick(target, source)

    return {}
Example #6
0
def act_straw(ircbot, conf, conn, event, data):
    global flg_straw_red
    global flg_prev_straw_state
    global thresh_red
    global stress
    global cnt_critical
    global flg_chg_stress

    # おこりんぼカウンタ
    if re.search(config.get('plugin:straw', 'critical_damage'), data['message']):
        stress = thresh_red + 1
        cnt_critical += 1
        logging.info('[straw] CRITICAL HIT.')
        flg_chg_stress = True
    elif re.search(config.get('plugin:straw', 'cooldown_pattern'), data['message']):
        stress = int(config.get('plugin:straw', 'initial_stress') or 0)
        logging.info('[straw] cooldown...')
        flg_chg_stress = True
    elif re.search(config.get('plugin:straw', 'stress_pattern'), data['message']):
        stress += 1
        flg_chg_stress = True
    elif re.search(config.get('plugin:straw', 'anti_stress_pattern'), data['message']):
        stress -= 1
        flg_chg_stress = True

    # 全部ログに出すのはちとつらいめう
    if flg_chg_stress:
        logging.info('[straw] thresh:%d count:%d state:%s prev:%s',
            thresh_red,
            stress,
            "RED" if flg_straw_red else "None",
            "RED" if flg_prev_straw_state else "None")
        flg_chg_stress = False

    # 堪忍袋の緒
    flg_prev_straw_state = flg_straw_red
    if stress > thresh_red:
        flg_straw_red = True
    else:
        flg_straw_red = False

    # 堪忍袋の緒のトリガエッジ検出
    #  - 怒りが収まった
    if flg_prev_straw_state is True and flg_straw_red is False:
        conn.notice(data['target'], config.get('plugin:straw', 'msg_normal_mode'))
        logging.info('[straw] detect state change to None.')
    #  - キレた
    elif flg_prev_straw_state is False and flg_straw_red is True:
        conn.notice(data['target'], config.get('plugin:straw', 'msg_stress_mode'))
        logging.info('[straw] detect state change to RED.')

    # 怒ってる
    if flg_straw_red:
        rnd = random.randint(1, 5)

        if rnd == 1:
            msg = config.get('plugin:straw', 'msg_type1')
            conn.notice(data['target'], msg) 
        elif rnd == 2:
            msg = config.get('plugin:straw', 'msg_type2')
            conn.notice(data['target'], msg) 
        elif rnd == 3:
            msg = config.get('plugin:straw', 'msg_type3')
            conn.notice(data['target'], msg) 
        elif rnd == 4:
            msg = config.get('plugin:straw', 'msg_type4')
            conn.notice(data['target'], msg) 
        elif rnd == 5:
            msg = config.get('plugin:straw', 'msg_type5')
            conn.notice(data['target'], msg) 
        elif rnd == 6:
            msg = config.get('plugin:straw', 'msg_type6')
            conn.notice(data['target'], msg) 
        else:
            msg = config.get('plugin:straw', 'msg_type7')
            conn.notice(data['target'], msg) 

        return {}

    else:
        return None
Example #7
0
#  [command:straw]
#  enable = true
# 
from amazonas import config
from amazonas import ircplugin
import logging
import random
import re

flg_straw_red = False 
flg_prev_straw_state = False
cnt_critical  = 0
flg_chg_stress = True

# おこりんぼ閾値
thresh_red = int(config.get('plugin:straw', 'threshold_stress') or 20)
# 堪忍袋
stress = int(config.get('plugin:straw', 'initial_stress') or 0)

@ircplugin.action('straw')
def act_straw(ircbot, conf, conn, event, data):
    global flg_straw_red
    global flg_prev_straw_state
    global thresh_red
    global stress
    global cnt_critical
    global flg_chg_stress

    # おこりんぼカウンタ
    if re.search(config.get('plugin:straw', 'critical_damage'), data['message']):
        stress = thresh_red + 1
Example #8
0
 def clear_flag():  
     global bloodmoon_flag  
     bloodmoon_flag = False  
     cmd_msg_stop = config.get('command:bloodmoon', 'msg_stop')
     conn.notice(data['target'], cmd_msg_stop) 
     logging.info('[bloodmoon] stop.')