Ejemplo n.º 1
0
def Http_Mail(emails, cc, msg, filelist):
    sub = status + ": " + msg['主题']
    newmsg = copy.deepcopy(msg)
    linkimg = newmsg['关联图']
    itemvalue = {"Data": newmsg['数据']}
    newmsg['状态'] += "  " + newmsg['监控图表']
    del newmsg['监控图表']
    del newmsg['关联图']
    del newmsg['数据']

    pre = "<hr>"
    #pre = "详情请登录 <a href=\"" + dashhome + "\">" + dashhome + "</a><br/><hr>"
    if status != "OK":
        ackurl = genAckLink(newmsg)
        if ackurl != "":
            pre = '<p><a href="' + ackurl + '">' + ackinfo + '</a></p>' + pre
    try:
        del newmsg['eventid']
    except:
        pass

    html = convert(newmsg,
                   build_direction=build_direction,
                   table_attributes=table_attributes)
    html_data = convert(itemvalue,
                        build_direction=build_direction,
                        table_attributes=table_attributes)
    if attachimg and show_linkimg:
        html = '<table><tr><td style="width:60%">' + html + '</td><td style="width:40%">' + linkimg + "</td></tr></table>"
    if not attachimg:
        filelist = []
    html = "<h3>基本信息</h3>" + html + "<br><h3>监控项数据</h3>" + html_data

    link = "<p><h3>报警对象影响范围图</h3></p><p>" + linkimg + "</p>"
    suffix = "<br><p><hr><b>" + team + "</b><br>主页: <a href=\"" + home + "\">" + home + "<br><hr><br></p>"
    #suffix = "<hr><br>" + link + "<br><hr><b>" + team + "</b><br>主页: <a href=\"" + home + "\">" + home + "<br><hr><br>"
    html = pre + html + suffix
    html = re.sub('</?(ul|li)>', '', html)
    http_send_attachmail(emails, cc, sub, html, filelist)
Ejemplo n.º 2
0
def bind(cmd, qq):
    count = len(cmd)
    user = cmd[1]
    if count == 2:
        password = randpass()
        db_bind.update(user, password)
        sub = "qqbot 绑定邮箱"
        content = "请向机器人发送以下指令完成绑定:   bind " + user + " " + password
        filelist = []
        try:
            ret = http_send_attachmail(config.get('mail', 'api'), user, sub,
                                       content, filelist)
            if ret['status'] != 0:
                return ("邮件发送异常:" + ret['msg'])
            else:
                return ("邮件已发送:" + user)
        except:
            return ("邮件发送异常")
    if count == 3:
        if db_bind.select(user) == cmd[2]:
            db_who.update(qq, user)
            return ("uin: " + qq + " 已绑定邮箱 " + user)
        else:
            return ("绑定失败")