Beispiel #1
0
def get_pipeline(data):
    outputs.append([data['channel'], "One moment please..."])
    wbdb = WarbotDB()
    pwc = PWClient(USERNAME, PASS, logger=logger)
    notifying_beiges = wbdb.beige_checks.find({"state": "notify"})
    watching_beiges = wbdb.beige_checks.find({"state": "watch"})

    total = notifying_beiges.count() + watching_beiges.count()
    if total > 1:
        outputs.append([data['channel'], "Processing "+str(total)+" records in the pipeline..."])
    else:
        return "The pipeline looks empty from here!"
    output_strings = []
    if notifying_beiges.count() > 0:
        output_strings.append("*Next turn notifications*")
    for record in notifying_beiges:
        user = get_username_from_user_id(record["requesting_user_slack_id"])
        output_strings.append("I am notifying "+user+" next turn about nation "+record["nation_name"] + "("+record["nation_id"]+")")

    if watching_beiges.count() > 0:
        output_strings.append("*Upcoming reminders*")
    for record in watching_beiges:
        try:
            nation = pwc.get_nation_obj_from_ID(record["nation_id"])
            user = get_username_from_user_id(record["requesting_user_slack_id"])
            output_strings.append("I am watching nation "+record["nation_name"] + "("+str(record["nation_id"])+") for "+user+". Has *"+str(nation.beige_turns_left)+"* turns left in beiege.")
        except NationDoesNotExistError as e:
            user = get_username_from_user_id(record["requesting_user_slack_id"])
            output_strings.append("I am watching nation "+record["nation_name"] + "("+str(record["nation_id"])+") for "+user+". However, *_the nation no longer exists!_*")
    return "\n".join(output_strings)
def process_message(data):
    print "new message...", data
    if not should_act_on_message(data):
        return
    if UNBEIGE.match(data['text']):
        username = get_username_from_user_id(data["user"])
        outputs.append([data['channel'], un_notify_end_of_beige(data["user"], username, data['text'])])
    elif END_OF_BEIGE.match(data['text']):
        username = get_username_from_user_id(data["user"])
        outputs.append([data['channel'], notify_end_of_beige(data["user"], username, data['text'])])
Beispiel #3
0
def process_message(data):
    print "new message...", data
    if not should_act_on_message(data):
        return
    if REGISTER.match(data['text']):
        username = get_username_from_user_id(data["user"])
        outputs.append([data['channel'], register_user(data["user"], username, data['text'])])
Beispiel #4
0
def process_message(data):
    print "new message...", data
    if not should_act_on_message(data):
        return
    text_data = data['text'].replace("warbot", "").replace("warby", "")
    if WATCH_MY_WAR.match(text_data):
        username = get_username_from_user_id(data["user"])
        outputs.append([data['channel'], watch_my_war(data["user"], username, text_data)])