def on_trigger(submit_id, submit_author, comment): """ On Trigger of bot :param submit_id: :param submit_author: :param comment: """ cid = comment.id try: cauthor = comment.author.name except AttributeError: return cbody = comment.body.lower() message = cbody.split(OfferBot.TRIGGER)[1].split("\n")[0] if "accept" in message: # UserManager.plus_job(cauthor) reply = get_response_accept(cauthor, submit_author) elif "plusrep" in message: # UserManager.plus_rep(cauthor) reply = get_response_plus_rep(cauthor, submit_author) elif "minusrep" in message: reason = message.split("minusrep")[1] reply = get_response_minus_rep(cauthor, submit_author, reason) elif "done" in message: reply = get_response_done(cauthor, submit_author) else: reply = get_response_user(cauthor) if UserManager.get_rep_level(DBManager.get_user(cauthor)['reputation']) == "Scammer": OfferBot.bot_reply(comment, get_response_scammer(cauthor)) OfferBot.bot_reply(comment, reply)
def get_response_plus_rep(user, op): """ OfferBot Tests :param user: """ user_info = DBManager.get_user(user) rep = user_info['reputation'] rep_string = UserManager.get_rep_level(rep) response = Template(config.get("offer", "plus_rep_reply")) response = response.substitute(username=user, username2=op, rep=rep_string, repno=rep) return response