from . import DINGTALK_CONF
import requests
import json

def send_msg(content, msgtype='markdown', contact=None, **kwargs):
    if not DINGTALK_CONF:
        return
    if not contact:
        contact=DINGTALK_CONF['mobile']
    url = 'https://oapi.dingtalk.com/robot/send?access_token=' + DINGTALK_CONF['access_token']
    headers = {'Content-type': 'application/json'}
    data = {
    'msgtype': msgtype,
    msgtype: build_msg_content(content=content, msgtype=msgtype, **kwargs),
    'at': {'atMobiles': [contact]}
    }
    resp = requests.post(url, headers=headers, data=json.dumps(data))
    return resp

def build_msg_content(content, msgtype, title='', msg_url='', pic_url='', **kwargs):
    if msgtype == 'markdown':
        data = {'title': title, 'text': content}
    elif msgtype == 'text':
        data = {'content': content}
    elif msgtype == 'link':
        data = {'title': title, 'text': content, 'messageUrl': msg_url, 'picUrl': pic_url}
    return data

@@ -465,16 +465,33 @@
 msgtype,
+ contact=contact,
  **kwarg
@@ -695,16 +695,30 @@
 _url='',
+ contact=None,
  **kwarg
@@ -790,32 +790,53 @@
  'text': content
+ + '%5Cn%5Cn @' + contact
 %7D%0A    elif msgty

fix markdown at issue;