mirror of
https://github.com/gissleh/irc.git
synced 2026-11-17 05:05:49 +00:00
This commit is contained in:
@@ -29,6 +29,7 @@ var supportedCaps = []string{
|
|||||||
"userhost-in-names",
|
"userhost-in-names",
|
||||||
"account-notify",
|
"account-notify",
|
||||||
"away-notify",
|
"away-notify",
|
||||||
|
"invite-notify",
|
||||||
"extended-join",
|
"extended-join",
|
||||||
"chghost",
|
"chghost",
|
||||||
"account-tag",
|
"account-tag",
|
||||||
@@ -885,7 +886,7 @@ func (client *Client) handleEvent(event *Event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddHandler ISupport
|
// ISupport
|
||||||
case "packet.005":
|
case "packet.005":
|
||||||
{
|
{
|
||||||
for _, token := range event.Args[1:] {
|
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":
|
case "packet.mode":
|
||||||
{
|
{
|
||||||
targetName := event.Arg(0)
|
targetName := event.Arg(0)
|
||||||
|
|||||||
+22
-1
@@ -18,6 +18,7 @@ func TestClient(t *testing.T) {
|
|||||||
RealName: "...",
|
RealName: "...",
|
||||||
Alternatives: []string{"Test2", "Test3", "Test4", "Test768"},
|
Alternatives: []string{"Test2", "Test3", "Test4", "Test768"},
|
||||||
SendRate: 1000,
|
SendRate: 1000,
|
||||||
|
AutoJoinInvites: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
client.AddHandler(handlers.Input)
|
client.AddHandler(handlers.Input)
|
||||||
@@ -34,6 +35,7 @@ func TestClient(t *testing.T) {
|
|||||||
{Client: "CAP LS 302"},
|
{Client: "CAP LS 302"},
|
||||||
{Client: "NICK Test"},
|
{Client: "NICK Test"},
|
||||||
{Client: "USER Tester 8 * :..."},
|
{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"},
|
{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"},
|
{Client: "CAP REQ :multi-prefix chghost userhost-in-names echo-message"},
|
||||||
{Server: ":testserver.example.com CAP * ACK :multi-prefix userhost-in-names"},
|
{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 {
|
if client.Channel("#Test2") != nil {
|
||||||
return errors.New("#Test2 is still there.")
|
return errors.New("#Test2 is still there.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
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"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ type Config struct {
|
|||||||
|
|
||||||
// Languages to request.
|
// Languages to request.
|
||||||
Languages []string `json:"languages"`
|
Languages []string `json:"languages"`
|
||||||
|
|
||||||
|
// Auto-join on invite (bad idea).
|
||||||
|
AutoJoinInvites bool `json:"autoJoinInvites"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithDefaults returns the config with the default values
|
// WithDefaults returns the config with the default values
|
||||||
|
|||||||
Reference in New Issue
Block a user