mirror of
https://github.com/gissleh/irc.git
synced 2026-09-29 00:05:34 +00:00
This commit is contained in:
@@ -29,6 +29,7 @@ var supportedCaps = []string{
|
||||
"userhost-in-names",
|
||||
"account-notify",
|
||||
"away-notify",
|
||||
"invite-notify",
|
||||
"extended-join",
|
||||
"chghost",
|
||||
"account-tag",
|
||||
@@ -885,7 +886,7 @@ func (client *Client) handleEvent(event *Event) {
|
||||
}
|
||||
}
|
||||
|
||||
// AddHandler ISupport
|
||||
// ISupport
|
||||
case "packet.005":
|
||||
{
|
||||
for _, token := range event.Args[1:] {
|
||||
@@ -1145,6 +1146,24 @@ func (client *Client) handleEvent(event *Event) {
|
||||
}
|
||||
}
|
||||
|
||||
case "packet.invite":
|
||||
{
|
||||
inviteeNick := event.Arg(0)
|
||||
channelName := event.Arg(1)
|
||||
channel := client.Channel(channelName)
|
||||
|
||||
if client.config.AutoJoinInvites && inviteeNick == client.Nick() {
|
||||
if channel == nil {
|
||||
client.Join(channelName)
|
||||
}
|
||||
}
|
||||
|
||||
// Add channel target for rendering invite-notify invitations.
|
||||
if channel != nil {
|
||||
client.handleInTarget(channel, event)
|
||||
}
|
||||
}
|
||||
|
||||
case "packet.mode":
|
||||
{
|
||||
targetName := event.Arg(0)
|
||||
|
||||
+27
-6
@@ -13,11 +13,12 @@ import (
|
||||
// Integration test below, brace yourself.
|
||||
func TestClient(t *testing.T) {
|
||||
client := irc.New(context.Background(), irc.Config{
|
||||
Nick: "Test",
|
||||
User: "Tester",
|
||||
RealName: "...",
|
||||
Alternatives: []string{"Test2", "Test3", "Test4", "Test768"},
|
||||
SendRate: 1000,
|
||||
Nick: "Test",
|
||||
User: "Tester",
|
||||
RealName: "...",
|
||||
Alternatives: []string{"Test2", "Test3", "Test4", "Test768"},
|
||||
SendRate: 1000,
|
||||
AutoJoinInvites: true,
|
||||
})
|
||||
|
||||
client.AddHandler(handlers.Input)
|
||||
@@ -34,6 +35,7 @@ func TestClient(t *testing.T) {
|
||||
{Client: "CAP LS 302"},
|
||||
{Client: "NICK Test"},
|
||||
{Client: "USER Tester 8 * :..."},
|
||||
{Server: ":testserver.example.com NOTICE * :*** Checking your bits..."},
|
||||
{Server: ":testserver.example.com CAP * LS :multi-prefix chghost userhost-in-names vendorname/custom-stuff echo-message =malformed vendorname/advanced-custom-stuff=things,and,items"},
|
||||
{Client: "CAP REQ :multi-prefix chghost userhost-in-names echo-message"},
|
||||
{Server: ":testserver.example.com CAP * ACK :multi-prefix userhost-in-names"},
|
||||
@@ -323,9 +325,28 @@ func TestClient(t *testing.T) {
|
||||
if client.Channel("#Test2") != nil {
|
||||
return errors.New("#Test2 is still there.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}},
|
||||
{Server: ":testserver.example.com CAP Test768 NEW :invite-notify"},
|
||||
{Client: "CAP REQ :invite-notify"},
|
||||
{Server: ":testserver.example.com CAP Test768 ACK :invite-notify"},
|
||||
{Server: ":ZealousMod!zeal@example.com INVITE Test768 #Test2"},
|
||||
{Client: "JOIN #Test2"},
|
||||
{Server: ":Test768!~Tester@127.0.0.1 JOIN #Test2 *"},
|
||||
{Server: ":testserver.example.com 353 Test768 = #Test2 :Test768!~Tester@127.0.0.1 @+ZealousMod!zeal@example.com"},
|
||||
{Server: ":testserver.example.com 366 Test768 #Test2 :End of /NAMES list."},
|
||||
{Server: "PING :testserver.example.com"}, // Ping/Pong to sync.
|
||||
{Client: "PONG :testserver.example.com"},
|
||||
{Callback: func() error {
|
||||
if client.Channel("#Test2") == nil {
|
||||
return errors.New("#Test2 is not there.")
|
||||
}
|
||||
return nil
|
||||
}},
|
||||
{Server: ":ZealousMod!zeal@example.com INVITE Test768 #Test2"},
|
||||
{Server: ":ZealousMod!zeal@example.com INVITE DoomedUser #test768-do-not-join"},
|
||||
{Server: "PING :testserver.example.com"}, // Ping/Pong to sync.
|
||||
{Client: "PONG :testserver.example.com"},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user