Browse Source

fix query messages' echoes not being put in right target.

master
Gisle Aune 4 years ago
parent
commit
07189d07ee
  1. 3
      client.go
  2. 24
      client_test.go

3
client.go

@ -1361,8 +1361,9 @@ func (client *Client) handleEvent(event *Event) {
// Target the message // Target the message
target := Target(client.status) target := Target(client.status)
targetName := event.Arg(0) targetName := event.Arg(0)
if targetName == client.nick { if targetName == client.nick {
queryTarget := client.Target("query", targetName)
queryTarget := client.Target("query", event.Nick)
if queryTarget == nil { if queryTarget == nil {
query := &Query{ query := &Query{
id: client.id, id: client.id,

24
client_test.go

@ -243,6 +243,30 @@ func TestClient(t *testing.T) {
}}, }},
{Client: "INVALIDCOMMAND stuff and things"}, {Client: "INVALIDCOMMAND stuff and things"},
{Server: ":testserver.example.com 421 Test768 INVALIDCOMMAND :Unknown command"}, {Server: ":testserver.example.com 421 Test768 INVALIDCOMMAND :Unknown command"},
{Callback: func() error {
client.Say("SevenAsterisks", "hi!")
return nil
}},
{Client: "PRIVMSG SevenAsterisks :hi!"},
{Server: ":Test768!~Tester@127.0.0.1 PRIVMSG SevenAsterisks :hi!"},
{Callback: func() error {
event := logger.Last("packet", "PRIVMSG")
if event == nil {
return errors.New("did not find last query message")
}
if event.QueryTarget() == nil {
return errors.New("event lacks query target")
}
if event.QueryTarget().Name() != "SevenAsterisks" {
return errors.New("incorrect query target")
}
return nil
}},
{Callback: func() error {
client.EmitInput("/invalidcommand stuff and things", nil)
return nil
}},
{Callback: func() error { {Callback: func() error {
channel := client.Channel("#Test") channel := client.Channel("#Test")
if channel == nil { if channel == nil {

Loading…
Cancel
Save