(msg, server)
handle a message and return an image
handle a message and return an image
handle a message and return an image
def on_message(msg, server):
    """handle a message and return an image"""
    text = msg.get("text", "")
    match = re.findall(r"!image (.*)", text)
    if not match:
        return

    res = image(match[0])
    if not res:
        return

    attachment = {
        "fallback": match[0],
        "title": match[0],
        "title_link": res,
        "image_url": res,
    }
    server.slack.post_message(
        msg["channel"],
        "",
        as_user=server.slack.username,
        attachments=json.dumps([attachment]),
        thread_ts=msg.get("thread_ts", None),
    )
def on_message ( msg , server ) : text = msg . get ( "text" , "" ) match = re . findall ( r"!image (.*)" , text ) if not match : return res = image ( match [ 0 ] ) if not res : return attachment = { "fallback" : match [ 0 ] , "title" : match [ 0 ] , "title_link" : res , "image_url" : res , } server . slack . post_message ( msg [ "channel" ] , "" , as_user = server . slack . username , attachments = json . dumps ( [ attachment ] ) , thread_ts = msg . get ( "thread_ts" , None ) , )