CQ 碼 🐴
- CQ 碼 🐴
CQTag
CQTag 為一個抽象類別,正常情況下並不會直接建立一個 CQTag 的實例,而是使用其子類別,如 CQAt、CQImage… 等。
CQTag 作為所有 CQ 碼的親類別。
CQTag tagName
tag.tagName
string
CQ碼功能名,如 "at"、"image"… 等。
CQTag data
tag.data
ReadOnly<object>
data 對象的值可能為 string, boolean 及 number。
data 對象包含的內容為,可能會出現在上報消息中的 CQ 碼參數,依照參數名稱,描述於 data 對象的各字段下。
如:上報消息中含有 "[CQ:at,qq=123456789]",則 tag.data 對象內容為 { qq: 123456789 }。
CQTag modifier
tag.modifier
object
只出現在API 調用中的 CQ 碼參數。
如:調用 API 發送圖片,若要禁用緩存,須加上之 cache 參數即為 modifier 的內容,CQ 碼為 "[CQ:image,cache=0,file=file]",modifier 對象內容為 { cache: 0 }。
CQTag equals
tag.equals(another)
anotherCQTag- 返回值:
boolean
若 another 非繼承自 CQTag 類別,則 false。
若 another.tagName 不同於 this.tagName,則 false。
若 another.data 與 this.data 進行 Deep Equal (strict mode) 比對不相符,則 false。
其餘返回 true。
CQTag coerce
tag.coerce()
- 返回值:
this
將 data 對象的值,依照各 CQ 碼的定義,強制轉型。
此方法為通常為內部使用。
CQTag toString
tag.toString()
- 返回值:
string
返回 CQ 碼的文字型態,如 "[CQ:at,qq=123456789]"。
CQTag valueOf
tag.valueOf()
- 返回值:
string
藉此方法,使 CQ 碼可以進行如字串相加… 等運算。
範例
const tag = new CQAt(123456789)
console.log(tag + ' 你好') // "[CQ:at,qq=123456789] 你好"
CQTag toJSON
tag.toJSON()
- 返回值: CQHTTPMessage
見 CQHTTP API 之消息段說明。
CQAnonymous
CQAnonymous constructor
new CQAnonymous([shouldIgnoreIfFailed])
shouldIgnoreIfFailedboolean [modifier]
CQAnonymous ignore
tag.ignore
boolean[modifier]
CQAt
CQAt constructor
new CQAt(qq)
qqnumber [data]
CQAt qq
tag.qq
ReadOnly<number>[data]
CQBFace
CQBFace constructor
new CQBFace(id, p)
idnumber [data]pstring [modifier]
關於這個神祕的 p,可以參考 CQ 码的坑。
CQBFace id
tag.id
ReadOnly<number>[data]
CQCustomMusic
CQCustomMusic constructor
new CQCustomMusic(url, audio, title[, content[, image]])
urlstring [data]audiostring [data]titlestring [data]contentstring [data]imagestring [data]
CQCustomMusic type
tag.type // "custom"
ReadOnly<"custom">[data]
CQCustomMusic url
tag.url
ReadOnly<string>[data]
CQCustomMusic audio
tag.audio
ReadOnly<string>[data]
CQCustomMusic title
tag.title
ReadOnly<string>[data]
CQCustomMusic content
tag.content
ReadOnly<string>[data]
CQCustomMusic image
tag.image
ReadOnly<string>[data]
CQDice
CQDice constructor
new CQDice()
CQDice type
tag.type
- ReadOnly
*[data]*
CQEmoji
CQEmoji constructor
new CQEmoji(id)
idnumber [data]
CQEmoji id
tag.id
ReadOnly<number>[data]
CQFace
CQFace constructor
new CQFace(id)
idnumber [data]
CQFace id
tag.id
ReadOnly<number>[data]
CQImage
CQImage constructor
new CQImage(file[, cache])
filestring [data]cacheboolean [modifier]
CQImage file
tag.file
ReadOnly<string>[data]
CQImage url
tag.url
ReadOnly<string>[data]
CQImage cache
tag.cache
boolean[modifier]
CQMusic
CQMusic constructor
new CQMusic(type, id)
typestring [data]idnumber [data]
CQMusic type
tag.type
ReadOnly<string>[data]
CQMusic id
tag.id
ReadOnly<number>[data]
CQRecord
CQRecord constructor
new CQRecord(file[, magic])
filestringmagicboolean
CQRecord file
tag.file
ReadOnly<string>[data]
CQRecord magic
tag.magic
true | undefined[modifier]
CQRecord hasMagic
tag.hasMagic()
- 返回值: boolean
CQRPS
CQRPS constructor
new CQRPS()
CQRPS type
tag.type
- ReadOnly
*[data]*
CQSFace
CQSFace constructor
new CQSFace(id)
idnumber [data]
CQSFace id
tag.id
ReadOnly<number>[data]
CQShake
CQShake constructor
new CQShake()
CQShare
CQShare constructor
new CQShare(url, title[, content[, image]])
urlstring [data]titlestring [data]contentstring [data]imagestring [data]
CQShare url
tag.url
ReadOnly<string>[data]
CQShare title
tag.title
ReadOnly<string>[data]
CQShare content
tag.content
ReadOnly<string>[data]
CQShare image
tag.image
ReadOnly<string>[data]
CQText
CQText constructor
new CQText(text)
textstring [data]
CQText text
tag.text
ReadOnly<string>[data]