예제 #1
0
    def admin_send_mail(cls, params):
        sid = params.get("sid")
        uids = params.get("uids")
        title = params.get("title")
        sender = params.get("sender")
        msg = params.get("msg")
        attachments = params.get("attachments")

        from apps.services.mail import MailService
        if str(uids) == "@all":
            receivers = rank_service.get_all_players(int(sid))
        else:
            receivers = str(uids).split("/")

        MailService.send_system(receivers, title, sender, msg, eval(attachments))

        return {"mc": 900002}
예제 #2
0
def debug(context):
    """api调试工具
    """
    # 测试副本获得星星,更新临时排行榜中数据

    ki_user = context.user
    action = context.get_parameter("action")

    if action == "clean_sign_data":
        ki_user.sign.last_sign = 0
        ki_user.sign.put()

    if action == "send_mails":
        from apps.services.mail import MailService
        # send(ids, mtype, title, fromwho, msg, attachments)
        for i in range(10):
            if i % 2 == 0:
                MailService.send_system(["110000004"], "test_%s" % i, "军需官",
                                        "我要一个打五个!!", {1: 10000 + i})
            else:
                MailService.send_system(["110000004"], "test_%s" % i, "军需官",
                                        "我要一个打五个!!", {})

    if action == "add_items":
        items = context.get_parameter("items", "{}")
        try:
            items = eval(items)
            if not isinstance(items, dict):
                raise 1
        except:
            context.result['mc'] = MsgCode['ParamIllegal']
            return

        import apps.logics.package as pack_logic
        pack_logic.add_items(ki_user, items)

    context.result["mc"] = 100
예제 #3
0
    def post(self):
        request_context = self.request.request_context
        method = request_context.get_parameter("method", "")

        result = {"mc": 100}
        if method == "add_game_value":
            items = request_context.get_parameter("items").strip()
            user_logic.add_game_values(request_context.user, eval(items))

        elif method == "reset_user_data":
            module = request_context.get_parameter("module").strip()

            debug_handle_reset_user_data(request_context.user, module)

        elif method == "add_items":
            items = request_context.get_parameter("items").strip()

            debug_handle_add_items(request_context.user, items)

        elif method == "send_mails":
            receiver = request_context.get_parameter("receiver").strip()
            title = request_context.get_parameter("title").strip()
            sender = request_context.get_parameter("sender").strip()
            msg = request_context.get_parameter("msg").strip()
            attachments = request_context.get_parameter("attachments").strip()
            attachments = eval(attachments)
            if not isinstance(attachments, dict):
                raise 1

            from apps.services.mail import MailService
            MailService.send_system([receiver], title, sender, msg,
                                    attachments)
        else:
            result = {"mc": 404}

        self.write(json_encode(result))