adc: usercommand support
--HG-- branch : adc
This commit is contained in:
parent
882f60f157
commit
4c32cb965e
@ -53,7 +53,7 @@ func NewAdcProtocol(hc *HubConnection) Protocol {
|
|||||||
proto.pid = pid_base32
|
proto.pid = pid_base32
|
||||||
|
|
||||||
// Start logging in
|
// Start logging in
|
||||||
hc.SayRaw("HSUP ADBASE ADTIGR\n")
|
hc.SayRaw("HSUP ADBASE ADTIGR ADUCMD\n")
|
||||||
|
|
||||||
return &proto
|
return &proto
|
||||||
}
|
}
|
||||||
@ -375,6 +375,49 @@ func (this *AdcProtocol) ProcessCommand(msg string) {
|
|||||||
msg := this.unescape(parts[3])
|
msg := this.unescape(parts[3])
|
||||||
this.hc.processEvent(HubEvent{EventType: EVENT_PRIVATE, Nick: senderNick, Message: msg})
|
this.hc.processEvent(HubEvent{EventType: EVENT_PRIVATE, Nick: senderNick, Message: msg})
|
||||||
|
|
||||||
|
case "ICMD":
|
||||||
|
// Usercommand
|
||||||
|
// ICMD ADCH++/About\sthis\shub TTHMSG\s+about\n CT3
|
||||||
|
|
||||||
|
if len(parts) < 2 {
|
||||||
|
this.malformed(parts)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uc := UserCommand{
|
||||||
|
Message: this.unescape(parts[1]),
|
||||||
|
Type: USERCOMMAND_TYPE_RAW, // default
|
||||||
|
}
|
||||||
|
|
||||||
|
flags, err := this.parts2flags(parts[2:])
|
||||||
|
if err != nil {
|
||||||
|
this.malformed(parts)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ct, ok := flags["CT"]; ok {
|
||||||
|
ct64, _ := strconv.ParseUint(ct, 10, 64)
|
||||||
|
uc.Context = UserCommandContext(ct64)
|
||||||
|
}
|
||||||
|
|
||||||
|
if tt, ok := flags["TT"]; ok {
|
||||||
|
uc.Command = tt
|
||||||
|
}
|
||||||
|
|
||||||
|
if sp, ok := flags["SP"]; ok && sp == "1" {
|
||||||
|
uc.Type = USERCOMMAND_TYPE_SEPARATOR
|
||||||
|
}
|
||||||
|
|
||||||
|
if co, ok := flags["CO"]; ok && co == "1" {
|
||||||
|
uc.Type = USERCOMMAND_TYPE_NICKLIMITED // "Constrained" in ADC parlance
|
||||||
|
}
|
||||||
|
|
||||||
|
if rm, ok := flags["RM"]; ok && rm == "1" {
|
||||||
|
uc.RemoveThis = true
|
||||||
|
}
|
||||||
|
|
||||||
|
this.hc.processEvent(HubEvent{EventType: EVENT_USERCOMMAND, UserCommand: &uc})
|
||||||
|
|
||||||
// Ignored messages
|
// Ignored messages
|
||||||
// ````````````````
|
// ````````````````
|
||||||
|
|
||||||
|
@ -19,8 +19,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type UserCommand struct {
|
type UserCommand struct {
|
||||||
Type UserCommandType
|
Type UserCommandType
|
||||||
Context UserCommandContext
|
Context UserCommandContext
|
||||||
Message string
|
Message string
|
||||||
Command string
|
Command string
|
||||||
|
RemoveThis bool // Currently only set by ADC hubs
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user