跳转至

消息

Message

Bases: WeChatMessage

用于处理微信服务器推送过来的消息

Attributes:

Name Type Description
__type__ str

【公共属性】消息类型

content str

【文本信息】文本消息内容

img

【图片信息】图片链接

title

【链接信息】消息标题

description

【链接信息】消息描述

url

【链接信息】消息链接

location_x

【位置信息】地理位置维度

location_y

【位置信息】地理位置经度

label

【位置信息】地理位置信息

scale

【位置信息】地图缩放大小

media_id

【音频信息】消息媒体ID

format

【语音信息】语音格式,如amr,speex等

recognition

【语音信息】语音识别结果,UTF8编码

thumb_media_id

【视频信息】视频消息缩略图的媒体id,可以调用多媒体文件下载接口拉取数据

Source code in zgrobot/messages/messages.py
class Message(WeChatMessage):
    """
    用于处理微信服务器推送过来的消息

    Attributes:
        __type__: 【公共属性】消息类型
        content (str): 【文本信息】文本消息内容
        img: 【图片信息】图片链接
        title: 【链接信息】消息标题
        description: 【链接信息】消息描述
        url: 【链接信息】消息链接
        location_x: 【位置信息】地理位置维度
        location_y: 【位置信息】地理位置经度
        label: 【位置信息】地理位置信息
        scale: 【位置信息】地图缩放大小
        media_id: 【音频信息】消息媒体ID
        format: 【语音信息】语音格式,如amr,speex等
        recognition: 【语音信息】语音识别结果,UTF8编码
        thumb_media_id: 【视频信息】视频消息缩略图的媒体id,可以调用多媒体文件下载接口拉取数据
    """
    __type__: str
    content = StringEntry('Content')
    img = StringEntry('PicUrl')
    title = StringEntry('Title')
    description = StringEntry('Description')
    url = StringEntry('Url')
    location_x = FloatEntry('Location_X')
    location_y = FloatEntry('Location_Y')
    label = StringEntry('Label')
    scale = IntEntry('Scale')
    media_id = StringEntry('MediaId')
    format = StringEntry('Format')
    recognition = StringEntry('Recognition')
    thumb_media_id = StringEntry('ThumbMediaId')

TextMessage

Bases: WeChatMessage

文本信息

Attributes:

Name Type Description
type str

text

content str

信息的内容

Source code in zgrobot/messages/messages.py
class TextMessage(WeChatMessage):
    """文本信息

    Attributes:
        type (str): text
        content (str): 信息的内容
    """
    __type__ = 'text'
    content = StringEntry('Content')

WeChatMessage

Bases: object

用于处理微信服务器推送过来的消息

Attributes:

Name Type Description
message_id

【公共属性】消息id,64位整型

target

【公共属性】开发者账号( OpenID )

source

【公共属性】发送方账号( OpenID )

time

【公共属性】信息发送的时间,一个UNIX时间戳。

Source code in zgrobot/messages/messages.py
class WeChatMessage(object, metaclass=MessageMetaClass):
    """
    用于处理微信服务器推送过来的消息

    Attributes:
        message_id: 【公共属性】消息id,64位整型
        target: 【公共属性】开发者账号( OpenID )
        source: 【公共属性】发送方账号( OpenID )
        time: 【公共属性】信息发送的时间,一个UNIX时间戳。
    """
    message_id = IntEntry('MsgId', 0)
    target = StringEntry('ToUserName')
    source = StringEntry('FromUserName')
    time = IntEntry('CreateTime', 0)

    def __init__(self, message):
        self.__dict__.update(message)