Search Results for

    Show / Hide Table of Contents

    Class ElementFile

    包括图片,语音

    Inheritance
    System.Object
    Element
    ElementFile
    ElementImage
    ElementRecord
    Inherited Members
    Element.type
    Element.data
    Element.isSingle
    Element.Equals(Object)
    Element.GetHashCode()
    Element.ToString()
    Element.GetElement(String, Dictionary<String, String>)
    Namespace: cqhttp.Cyan.Messages.CQElements.Base
    Assembly: cqhttp.Cyan.dll
    Syntax
    public class ElementFile : Element

    Constructors

    | Improve this Doc View Source

    ElementFile(String, Dictionary<String, String>)

    构造消息段,一般不会手动调用

    Declaration
    public ElementFile(string type, Dictionary<string, string> data)
    Parameters
    Type Name Description
    System.String type

    消息段类型

    Dictionary<System.String, System.String> data

    消息段键值对

    | Improve this Doc View Source

    ElementFile(String, Byte[], Boolean)

    通过byte array构造文件消息段

    Declaration
    public ElementFile(string type, byte[] bytes, bool use_cache)
    Parameters
    Type Name Description
    System.String type

    消息段种类

    System.Byte[] bytes
    System.Boolean use_cache
    | Improve this Doc View Source

    ElementFile(String, String, Boolean)

    通过url构建文件消息段

    Declaration
    public ElementFile(string type, string url, bool use_cache)
    Parameters
    Type Name Description
    System.String type

    消息段种类

    System.String url
    System.Boolean use_cache

    是否缓存于酷Q端

    | Improve this Doc View Source

    ElementFile(String, (String key, String val)[])

    手动构造一个消息段,一般用不到

    Declaration
    public ElementFile(string type, params (string key, string val)[] dict)
    Parameters
    Type Name Description
    System.String type

    消息段类型

    System.ValueTuple<System.String, System.String>[] dict

    手动输入的键值对

    Properties

    | Improve this Doc View Source

    file_url

    stores the location of the file could be base64://, http(s):// or file:// https://tools.ietf.org/html/rfc8089

    Declaration
    public string file_url { get; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    is_fixed

    represents whether the file has downloaded

    Declaration
    public bool is_fixed { get; }
    Property Value
    Type Description
    System.Boolean

    Methods

    | Improve this Doc View Source

    Fix()

    下载图片并转为base64存储,并删除data中的url项 网络环境恶劣的情况下最多获取network_max_failure次 若仍需url可从file_url中获取

    Declaration
    public Task<bool> Fix()
    Returns
    Type Description
    Task<System.Boolean>

    返回是否成功获取到

    | Improve this Doc View Source

    Save(String)

    保存为本地文件

    Declaration
    public Task<bool> Save(string file_name)
    Parameters
    Type Name Description
    System.String file_name

    存储的文件名

    Returns
    Type Description
    Task<System.Boolean>

    是否成功保存

    • Improve this Doc
    • View Source
    ☀
    ☾