Browse Source

Added targeting of messages, notices and ctcp actions (untested), added account-tag support

master
Gisle Aune 6 years ago
parent
commit
0fbebfc3f5
  1. 6
      channel.go
  2. 61
      client.go

6
channel.go

@ -123,5 +123,11 @@ func (channel *Channel) Handle(event *Event, client *Client) {
}
}
}
case "packet.privmsg", "ctcp.action":
{
if accountTag, ok := event.Tags["account"]; ok && accountTag != "" {
channel.userlist.Patch(event.Nick, list.UserPatch{Account: accountTag})
}
}
}
}

61
client.go

@ -30,6 +30,7 @@ var supportedCaps = []string{
"away-notify",
"extended-join",
"chghost",
"account-tag",
}
// ErrNoConnection is returned if you try to do something requiring a connection,
@ -859,6 +860,66 @@ func (client *Client) handleEvent(event *Event) {
}
}
// Message parsing
case "packet.privmsg", "ctcp.action":
{
// Target the mssage
target := Target(client.status)
spawned := false
targetName := event.Arg(0)
if targetName == client.nick {
target := client.Target("query", targetName)
if target == nil {
query := &Query{user: list.User{
Nick: event.Nick,
User: event.User,
Host: event.Host,
}}
client.AddTarget(query)
spawned = true
target = query
}
} else {
target = client.Channel(targetName)
if target == nil {
target = client.status
}
}
target.Handle(event, client)
event.targets = append(event.targets, target)
if spawned {
// TODO: Message has higher importance // 0:Normal, 1:Important, 2:Highlight
}
}
case "packet.notice":
{
// Try to target by mentioned channel name
for _, token := range strings.Fields(event.Text) {
if client.isupport.IsChannel(token) {
channel := client.Channel(token)
if channel == nil {
continue
}
channel.Handle(event, client)
event.targets = append(event.targets, channel)
break
}
}
// Otherwise, it belongs in the status target
if len(event.targets) == 0 {
client.status.Handle(event, client)
event.targets = append(event.targets, client.status)
}
}
// account-notify
case "packet.account":
{

Loading…
Cancel
Save