mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-06 03:53:50 +08:00
feat: supported finger-guessing message (#1519)
This commit is contained in:
parent
c275806c62
commit
43ea459365
@ -248,6 +248,13 @@ func toElements(e []message.IMessageElement, source message.Source, raw bool) (r
|
|||||||
{"value", strconv.FormatInt(int64(o.Value), 10)},
|
{"value", strconv.FormatInt(int64(o.Value), 10)},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
case *message.FingerGuessingElement:
|
||||||
|
m = cqcode.Element{
|
||||||
|
Type: "rps",
|
||||||
|
Data: pairs{
|
||||||
|
{"value", strconv.FormatInt(int64(o.Value), 10)},
|
||||||
|
},
|
||||||
|
}
|
||||||
case *message.MarketFaceElement:
|
case *message.MarketFaceElement:
|
||||||
m = cqcode.Element{
|
m = cqcode.Element{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
@ -371,6 +378,8 @@ func ToMessageContent(e []message.IMessageElement) (r []global.MSG) {
|
|||||||
}
|
}
|
||||||
case *message.DiceElement:
|
case *message.DiceElement:
|
||||||
m = global.MSG{"type": "dice", "data": global.MSG{"value": o.Value}}
|
m = global.MSG{"type": "dice", "data": global.MSG{"value": o.Value}}
|
||||||
|
case *message.FingerGuessingElement:
|
||||||
|
m = global.MSG{"type": "rps", "data": global.MSG{"value": o.Value}}
|
||||||
case *message.MarketFaceElement:
|
case *message.MarketFaceElement:
|
||||||
m = global.MSG{"type": "text", "data": global.MSG{"text": o.Name}}
|
m = global.MSG{"type": "text", "data": global.MSG{"text": o.Name}}
|
||||||
case *message.ServiceElement:
|
case *message.ServiceElement:
|
||||||
@ -964,6 +973,13 @@ func (bot *CQBot) ToElement(t string, d map[string]string, sourceType message.So
|
|||||||
return nil, errors.New("invalid dice value " + value)
|
return nil, errors.New("invalid dice value " + value)
|
||||||
}
|
}
|
||||||
return message.NewDice(int32(i)), nil
|
return message.NewDice(int32(i)), nil
|
||||||
|
case "rps":
|
||||||
|
value := d["value"]
|
||||||
|
i, _ := strconv.ParseInt(value, 10, 64)
|
||||||
|
if i < 0 || i > 2 {
|
||||||
|
return nil, errors.New("invalid finger-guessing value " + value)
|
||||||
|
}
|
||||||
|
return message.NewFingerGuessing(int32(i)), nil
|
||||||
case "xml":
|
case "xml":
|
||||||
resID := d["resid"]
|
resID := d["resid"]
|
||||||
template := cqcode.EscapeValue(d["data"])
|
template := cqcode.EscapeValue(d["data"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user