Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38d222f6a7 | ||
|
|
8e3166969e | ||
|
|
8d91ad852c |
No files matched your search
+116
-58
@@ -28,6 +28,18 @@ const (
|
||||
defaultHistLimit = 50
|
||||
maxHistLimit = 500
|
||||
cmdPrivmsg = "PRIVMSG"
|
||||
|
||||
// IRC numeric reply codes per RFC 1459/2812.
|
||||
ircErrNoSuchNick = "401"
|
||||
ircErrNoSuchChannel = "403"
|
||||
ircErrNoRecipient = "411"
|
||||
ircErrNoTextToSend = "412"
|
||||
ircErrUnknownCommand = "421"
|
||||
ircErrNoNicknameGiven = "431"
|
||||
ircErrErroneusNickname = "432"
|
||||
ircErrNicknameInUse = "433"
|
||||
ircErrNotOnChannel = "442"
|
||||
ircErrNeedMoreParams = "461"
|
||||
)
|
||||
|
||||
func (hdlr *Handlers) maxBodySize() int64 {
|
||||
@@ -63,6 +75,43 @@ func (hdlr *Handlers) authSession(
|
||||
return sessionID, clientID, nick, nil
|
||||
}
|
||||
|
||||
// serverName returns the configured server name or the
|
||||
// default "neoirc".
|
||||
func (hdlr *Handlers) serverName() string {
|
||||
if hdlr.params.Config.ServerName != "" {
|
||||
return hdlr.params.Config.ServerName
|
||||
}
|
||||
|
||||
return "neoirc"
|
||||
}
|
||||
|
||||
// respondIRCError sends an IRC numeric error reply as a
|
||||
// JSON response with HTTP 200 OK. This is used for errors
|
||||
// in IRC command processing (as opposed to HTTP transport
|
||||
// errors). The params slice contains IRC-style positional
|
||||
// parameters (e.g. the target nick or channel).
|
||||
func (hdlr *Handlers) respondIRCError(
|
||||
writer http.ResponseWriter,
|
||||
request *http.Request,
|
||||
nick, numeric, msg string,
|
||||
params ...string,
|
||||
) {
|
||||
resp := map[string]any{
|
||||
"command": numeric,
|
||||
"from": hdlr.serverName(),
|
||||
"to": nick,
|
||||
"body": []string{msg},
|
||||
}
|
||||
|
||||
if len(params) > 0 {
|
||||
resp["params"] = params
|
||||
}
|
||||
|
||||
hdlr.respondJSON(
|
||||
writer, request, resp, http.StatusOK,
|
||||
)
|
||||
}
|
||||
|
||||
func (hdlr *Handlers) requireAuth(
|
||||
writer http.ResponseWriter,
|
||||
request *http.Request,
|
||||
@@ -226,11 +275,7 @@ func (hdlr *Handlers) deliverMOTD(
|
||||
clientID, sessionID int64,
|
||||
) {
|
||||
motd := hdlr.params.Config.MOTD
|
||||
serverName := hdlr.params.Config.ServerName
|
||||
|
||||
if serverName == "" {
|
||||
serverName = "neoirc"
|
||||
}
|
||||
serverName := hdlr.serverName()
|
||||
|
||||
if motd == "" {
|
||||
return
|
||||
@@ -557,10 +602,10 @@ func (hdlr *Handlers) HandleSendCommand() http.HandlerFunc {
|
||||
payload.To = strings.TrimSpace(payload.To)
|
||||
|
||||
if payload.Command == "" {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"command required",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrUnknownCommand,
|
||||
"No command given",
|
||||
)
|
||||
|
||||
return
|
||||
@@ -631,10 +676,11 @@ func (hdlr *Handlers) dispatchCommand(
|
||||
},
|
||||
http.StatusOK)
|
||||
default:
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"unknown command: "+command,
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrUnknownCommand,
|
||||
command+" :Unknown command",
|
||||
command,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -648,10 +694,10 @@ func (hdlr *Handlers) handlePrivmsg(
|
||||
bodyLines func() []string,
|
||||
) {
|
||||
if target == "" {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"to field required",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrNoRecipient,
|
||||
"No recipient given ("+command+")",
|
||||
)
|
||||
|
||||
return
|
||||
@@ -659,10 +705,10 @@ func (hdlr *Handlers) handlePrivmsg(
|
||||
|
||||
lines := bodyLines()
|
||||
if len(lines) == 0 {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"body required",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrNoTextToSend,
|
||||
"No text to send",
|
||||
)
|
||||
|
||||
return
|
||||
@@ -694,10 +740,11 @@ func (hdlr *Handlers) handleChannelMsg(
|
||||
request.Context(), target,
|
||||
)
|
||||
if err != nil {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"channel not found",
|
||||
http.StatusNotFound,
|
||||
nick, ircErrNoSuchChannel,
|
||||
"No such channel",
|
||||
target,
|
||||
)
|
||||
|
||||
return
|
||||
@@ -720,10 +767,11 @@ func (hdlr *Handlers) handleChannelMsg(
|
||||
}
|
||||
|
||||
if !isMember {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"not a member of this channel",
|
||||
http.StatusForbidden,
|
||||
nick, ircErrNotOnChannel,
|
||||
"You're not on that channel",
|
||||
target,
|
||||
)
|
||||
|
||||
return
|
||||
@@ -761,7 +809,7 @@ func (hdlr *Handlers) handleChannelMsg(
|
||||
|
||||
hdlr.respondJSON(writer, request,
|
||||
map[string]string{"id": msgUUID, "status": "sent"},
|
||||
http.StatusCreated)
|
||||
http.StatusOK)
|
||||
}
|
||||
|
||||
func (hdlr *Handlers) handleDirectMsg(
|
||||
@@ -775,10 +823,11 @@ func (hdlr *Handlers) handleDirectMsg(
|
||||
request.Context(), target,
|
||||
)
|
||||
if err != nil {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"user not found",
|
||||
http.StatusNotFound,
|
||||
nick, ircErrNoSuchNick,
|
||||
"No such nick/channel",
|
||||
target,
|
||||
)
|
||||
|
||||
return
|
||||
@@ -805,7 +854,7 @@ func (hdlr *Handlers) handleDirectMsg(
|
||||
|
||||
hdlr.respondJSON(writer, request,
|
||||
map[string]string{"id": msgUUID, "status": "sent"},
|
||||
http.StatusCreated)
|
||||
http.StatusOK)
|
||||
}
|
||||
|
||||
func (hdlr *Handlers) handleJoin(
|
||||
@@ -815,10 +864,11 @@ func (hdlr *Handlers) handleJoin(
|
||||
nick, target string,
|
||||
) {
|
||||
if target == "" {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"to field required",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrNeedMoreParams,
|
||||
"Not enough parameters",
|
||||
"JOIN",
|
||||
)
|
||||
|
||||
return
|
||||
@@ -830,10 +880,11 @@ func (hdlr *Handlers) handleJoin(
|
||||
}
|
||||
|
||||
if !validChannelRe.MatchString(channel) {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"invalid channel name",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrNoSuchChannel,
|
||||
"No such channel",
|
||||
channel,
|
||||
)
|
||||
|
||||
return
|
||||
@@ -895,10 +946,11 @@ func (hdlr *Handlers) handlePart(
|
||||
body json.RawMessage,
|
||||
) {
|
||||
if target == "" {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"to field required",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrNeedMoreParams,
|
||||
"Not enough parameters",
|
||||
"PART",
|
||||
)
|
||||
|
||||
return
|
||||
@@ -913,10 +965,11 @@ func (hdlr *Handlers) handlePart(
|
||||
request.Context(), channel,
|
||||
)
|
||||
if err != nil {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"channel not found",
|
||||
http.StatusNotFound,
|
||||
nick, ircErrNoSuchChannel,
|
||||
"No such channel",
|
||||
channel,
|
||||
)
|
||||
|
||||
return
|
||||
@@ -967,10 +1020,10 @@ func (hdlr *Handlers) handleNick(
|
||||
) {
|
||||
lines := bodyLines()
|
||||
if len(lines) == 0 {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"body required (new nick)",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrNoNicknameGiven,
|
||||
"No nickname given",
|
||||
)
|
||||
|
||||
return
|
||||
@@ -979,10 +1032,11 @@ func (hdlr *Handlers) handleNick(
|
||||
newNick := strings.TrimSpace(lines[0])
|
||||
|
||||
if !validNickRe.MatchString(newNick) {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"invalid nick",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrErroneusNickname,
|
||||
"Erroneous nickname",
|
||||
newNick,
|
||||
)
|
||||
|
||||
return
|
||||
@@ -1003,10 +1057,11 @@ func (hdlr *Handlers) handleNick(
|
||||
)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "UNIQUE") {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"nick already in use",
|
||||
http.StatusConflict,
|
||||
nick, ircErrNicknameInUse,
|
||||
"Nickname is already in use",
|
||||
newNick,
|
||||
)
|
||||
|
||||
return
|
||||
@@ -1093,10 +1148,11 @@ func (hdlr *Handlers) handleTopic(
|
||||
bodyLines func() []string,
|
||||
) {
|
||||
if target == "" {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"to field required",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrNeedMoreParams,
|
||||
"Not enough parameters",
|
||||
"TOPIC",
|
||||
)
|
||||
|
||||
return
|
||||
@@ -1104,10 +1160,11 @@ func (hdlr *Handlers) handleTopic(
|
||||
|
||||
lines := bodyLines()
|
||||
if len(lines) == 0 {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"body required (topic text)",
|
||||
http.StatusBadRequest,
|
||||
nick, ircErrNeedMoreParams,
|
||||
"Not enough parameters",
|
||||
"TOPIC",
|
||||
)
|
||||
|
||||
return
|
||||
@@ -1140,10 +1197,11 @@ func (hdlr *Handlers) handleTopic(
|
||||
request.Context(), channel,
|
||||
)
|
||||
if err != nil {
|
||||
hdlr.respondError(
|
||||
hdlr.respondIRCError(
|
||||
writer, request,
|
||||
"channel not found",
|
||||
http.StatusNotFound,
|
||||
nick, ircErrNoSuchChannel,
|
||||
"No such channel",
|
||||
channel,
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
+124
-40
@@ -668,11 +668,18 @@ func TestJoinMissingTo(t *testing.T) {
|
||||
tserver := newTestServer(t)
|
||||
token := tserver.createSession("joiner3")
|
||||
|
||||
status, _ := tserver.sendCommand(
|
||||
status, result := tserver.sendCommand(
|
||||
token, map[string]any{commandKey: joinCmd},
|
||||
)
|
||||
if status != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "461" {
|
||||
t.Fatalf(
|
||||
"expected IRC 461, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,9 +706,9 @@ func TestChannelMessage(t *testing.T) {
|
||||
bodyKey: []string{"hello world"},
|
||||
},
|
||||
)
|
||||
if status != http.StatusCreated {
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf(
|
||||
"expected 201, got %d: %v", status, result,
|
||||
"expected 200, got %d: %v", status, result,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -728,11 +735,18 @@ func TestMessageMissingBody(t *testing.T) {
|
||||
commandKey: joinCmd, toKey: "#test",
|
||||
})
|
||||
|
||||
status, _ := tserver.sendCommand(token, map[string]any{
|
||||
status, result := tserver.sendCommand(token, map[string]any{
|
||||
commandKey: privmsgCmd, toKey: "#test",
|
||||
})
|
||||
if status != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "412" {
|
||||
t.Fatalf(
|
||||
"expected IRC 412, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -740,12 +754,19 @@ func TestMessageMissingTo(t *testing.T) {
|
||||
tserver := newTestServer(t)
|
||||
token := tserver.createSession("noto")
|
||||
|
||||
status, _ := tserver.sendCommand(token, map[string]any{
|
||||
status, result := tserver.sendCommand(token, map[string]any{
|
||||
commandKey: privmsgCmd,
|
||||
bodyKey: []string{"hello"},
|
||||
})
|
||||
if status != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "411" {
|
||||
t.Fatalf(
|
||||
"expected IRC 411, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,7 +781,7 @@ func TestNonMemberCannotSend(t *testing.T) {
|
||||
})
|
||||
|
||||
// Alice tries to send without joining.
|
||||
status, _ := tserver.sendCommand(
|
||||
status, result := tserver.sendCommand(
|
||||
aliceToken,
|
||||
map[string]any{
|
||||
commandKey: privmsgCmd,
|
||||
@@ -768,8 +789,15 @@ func TestNonMemberCannotSend(t *testing.T) {
|
||||
bodyKey: []string{"sneaky"},
|
||||
},
|
||||
)
|
||||
if status != http.StatusForbidden {
|
||||
t.Fatalf("expected 403, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "442" {
|
||||
t.Fatalf(
|
||||
"expected IRC 442, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -786,9 +814,9 @@ func TestDirectMessage(t *testing.T) {
|
||||
bodyKey: []string{"hey bob"},
|
||||
},
|
||||
)
|
||||
if status != http.StatusCreated {
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf(
|
||||
"expected 201, got %d: %v", status, result,
|
||||
"expected 200, got %d: %v", status, result,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -818,13 +846,20 @@ func TestDMToNonexistentUser(t *testing.T) {
|
||||
tserver := newTestServer(t)
|
||||
token := tserver.createSession("dmsender")
|
||||
|
||||
status, _ := tserver.sendCommand(token, map[string]any{
|
||||
status, result := tserver.sendCommand(token, map[string]any{
|
||||
commandKey: privmsgCmd,
|
||||
toKey: "nobody",
|
||||
bodyKey: []string{"hello?"},
|
||||
})
|
||||
if status != http.StatusNotFound {
|
||||
t.Fatalf("expected 404, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "401" {
|
||||
t.Fatalf(
|
||||
"expected IRC 401, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,12 +906,19 @@ func TestNickCollision(t *testing.T) {
|
||||
|
||||
tserver.createSession("taken_nick")
|
||||
|
||||
status, _ := tserver.sendCommand(token, map[string]any{
|
||||
status, result := tserver.sendCommand(token, map[string]any{
|
||||
commandKey: "NICK",
|
||||
bodyKey: []string{"taken_nick"},
|
||||
})
|
||||
if status != http.StatusConflict {
|
||||
t.Fatalf("expected 409, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "433" {
|
||||
t.Fatalf(
|
||||
"expected IRC 433, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -884,12 +926,19 @@ func TestNickInvalid(t *testing.T) {
|
||||
tserver := newTestServer(t)
|
||||
token := tserver.createSession("nickval")
|
||||
|
||||
status, _ := tserver.sendCommand(token, map[string]any{
|
||||
status, result := tserver.sendCommand(token, map[string]any{
|
||||
commandKey: "NICK",
|
||||
bodyKey: []string{"bad nick!"},
|
||||
})
|
||||
if status != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "432" {
|
||||
t.Fatalf(
|
||||
"expected IRC 432, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -897,11 +946,18 @@ func TestNickEmptyBody(t *testing.T) {
|
||||
tserver := newTestServer(t)
|
||||
token := tserver.createSession("nicknobody")
|
||||
|
||||
status, _ := tserver.sendCommand(
|
||||
status, result := tserver.sendCommand(
|
||||
token, map[string]any{commandKey: "NICK"},
|
||||
)
|
||||
if status != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "431" {
|
||||
t.Fatalf(
|
||||
"expected IRC 431, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -938,12 +994,19 @@ func TestTopicMissingTo(t *testing.T) {
|
||||
tserver := newTestServer(t)
|
||||
token := tserver.createSession("topicnoto")
|
||||
|
||||
status, _ := tserver.sendCommand(token, map[string]any{
|
||||
status, result := tserver.sendCommand(token, map[string]any{
|
||||
commandKey: "TOPIC",
|
||||
bodyKey: []string{"topic"},
|
||||
})
|
||||
if status != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "461" {
|
||||
t.Fatalf(
|
||||
"expected IRC 461, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -955,11 +1018,18 @@ func TestTopicMissingBody(t *testing.T) {
|
||||
commandKey: joinCmd, toKey: "#topictest",
|
||||
})
|
||||
|
||||
status, _ := tserver.sendCommand(token, map[string]any{
|
||||
status, result := tserver.sendCommand(token, map[string]any{
|
||||
commandKey: "TOPIC", toKey: "#topictest",
|
||||
})
|
||||
if status != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "461" {
|
||||
t.Fatalf(
|
||||
"expected IRC 461, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1027,11 +1097,18 @@ func TestUnknownCommand(t *testing.T) {
|
||||
tserver := newTestServer(t)
|
||||
token := tserver.createSession("cmdtest")
|
||||
|
||||
status, _ := tserver.sendCommand(
|
||||
status, result := tserver.sendCommand(
|
||||
token, map[string]any{commandKey: "BOGUS"},
|
||||
)
|
||||
if status != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "421" {
|
||||
t.Fatalf(
|
||||
"expected IRC 421, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,11 +1116,18 @@ func TestEmptyCommand(t *testing.T) {
|
||||
tserver := newTestServer(t)
|
||||
token := tserver.createSession("emptycmd")
|
||||
|
||||
status, _ := tserver.sendCommand(
|
||||
status, result := tserver.sendCommand(
|
||||
token, map[string]any{commandKey: ""},
|
||||
)
|
||||
if status != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", status)
|
||||
}
|
||||
|
||||
if result[commandKey] != "421" {
|
||||
t.Fatalf(
|
||||
"expected IRC 421, got %v",
|
||||
result[commandKey],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -1,2 +1,2 @@
|
||||
var ae,S,He,ht,K,Ae,Re,De,Le,he,de,pe,yt,X={},je=[],vt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_e=Array.isArray;function J(e,t){for(var n in t)e[n]=t[n];return e}function ye(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function y(e,t,n){var r,a,s,c={};for(s in t)s=="key"?r=t[s]:s=="ref"?a=t[s]:c[s]=t[s];if(arguments.length>2&&(c.children=arguments.length>3?ae.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)c[s]===void 0&&(c[s]=e.defaultProps[s]);return oe(e,c,r,a,null)}function oe(e,t,n,r,a){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++He,__i:-1,__u:0};return a==null&&S.vnode!=null&&S.vnode(s),s}function ce(e){return e.children}function re(e,t){this.props=e,this.context=t}function Q(e,t){if(t==null)return e.__?Q(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Q(e):null}function We(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return We(e)}}function Oe(e){(!e.__d&&(e.__d=!0)&&K.push(e)&&!se.__r++||Ae!=S.debounceRendering)&&((Ae=S.debounceRendering)||Re)(se)}function se(){for(var e,t,n,r,a,s,c,u=1;K.length;)K.length>u&&K.sort(De),e=K.shift(),u=K.length,e.__d&&(n=void 0,r=void 0,a=(r=(t=e).__v).__e,s=[],c=[],t.__P&&((n=J({},r)).__v=r.__v+1,S.vnode&&S.vnode(n),ve(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?[a]:null,s,a??Q(r),!!(32&r.__u),c),n.__v=r.__v,n.__.__k[n.__i]=n,Be(s,n,c),r.__e=r.__=null,n.__e!=a&&We(n)));se.__r=0}function Fe(e,t,n,r,a,s,c,u,v,l,b){var _,m,h,T,A,x,g,k=r&&r.__k||je,O=t.length;for(v=bt(n,t,k,v,O),_=0;_<O;_++)(h=n.__k[_])!=null&&(m=h.__i==-1?X:k[h.__i]||X,h.__i=_,x=ve(e,h,m,a,s,c,u,v,l,b),T=h.__e,h.ref&&m.ref!=h.ref&&(m.ref&&be(m.ref,null,h),b.push(h.ref,h.__c||T,h)),A==null&&T!=null&&(A=T),(g=!!(4&h.__u))||m.__k===h.__k?v=Je(h,v,e,g):typeof h.type=="function"&&x!==void 0?v=x:T&&(v=T.nextSibling),h.__u&=-7);return n.__e=A,v}function bt(e,t,n,r,a){var s,c,u,v,l,b=n.length,_=b,m=0;for(e.__k=new Array(a),s=0;s<a;s++)(c=t[s])!=null&&typeof c!="boolean"&&typeof c!="function"?(typeof c=="string"||typeof c=="number"||typeof c=="bigint"||c.constructor==String?c=e.__k[s]=oe(null,c,null,null,null):_e(c)?c=e.__k[s]=oe(ce,{children:c},null,null,null):c.constructor===void 0&&c.__b>0?c=e.__k[s]=oe(c.type,c.props,c.key,c.ref?c.ref:null,c.__v):e.__k[s]=c,v=s+m,c.__=e,c.__b=e.__b+1,u=null,(l=c.__i=kt(c,n,v,_))!=-1&&(_--,(u=n[l])&&(u.__u|=2)),u==null||u.__v==null?(l==-1&&(a>b?m--:a<b&&m++),typeof c.type!="function"&&(c.__u|=4)):l!=v&&(l==v-1?m--:l==v+1?m++:(l>v?m--:m++,c.__u|=4))):e.__k[s]=null;if(_)for(s=0;s<b;s++)(u=n[s])!=null&&(2&u.__u)==0&&(u.__e==r&&(r=Q(u)),qe(u,u));return r}function Je(e,t,n,r){var a,s;if(typeof e.type=="function"){for(a=e.__k,s=0;a&&s<a.length;s++)a[s]&&(a[s].__=e,t=Je(a[s],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Q(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function kt(e,t,n,r){var a,s,c,u=e.key,v=e.type,l=t[n],b=l!=null&&(2&l.__u)==0;if(l===null&&u==null||b&&u==l.key&&v==l.type)return n;if(r>(b?1:0)){for(a=n-1,s=n+1;a>=0||s<t.length;)if((l=t[c=a>=0?a--:s++])!=null&&(2&l.__u)==0&&u==l.key&&v==l.type)return c}return-1}function $e(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||vt.test(t)?n:n+"px"}function ne(e,t,n,r,a){var s,c;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||$e(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||$e(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(Le,"$1")),c=t.toLowerCase(),t=c in e||t=="onFocusOut"||t=="onFocusIn"?c.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n.u=r.u:(n.u=he,e.addEventListener(t,s?pe:de,s)):e.removeEventListener(t,s?pe:de,s);else{if(a=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Ue(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=he++;else if(t.t<n.u)return;return n(S.event?S.event(t):t)}}}function ve(e,t,n,r,a,s,c,u,v,l){var b,_,m,h,T,A,x,g,k,O,j,V,H,te,B,R,q,$=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(v=!!(32&n.__u),s=[u=t.__e=n.__e]),(b=S.__b)&&b(t);e:if(typeof $=="function")try{if(g=t.props,k="prototype"in $&&$.prototype.render,O=(b=$.contextType)&&r[b.__c],j=b?O?O.props.value:b.__:r,n.__c?x=(_=t.__c=n.__c).__=_.__E:(k?t.__c=_=new $(g,j):(t.__c=_=new re(g,j),_.constructor=$,_.render=St),O&&O.sub(_),_.state||(_.state={}),_.__n=r,m=_Line truncated
|
||||
`):"",f={id:o.id,ts:o.ts,from:o.from,to:o.to,command:o.command},d=o.meta&&o.meta.action;switch(o.command){case"PRIVMSG":case"NOTICE":{let p={...f,text:i,system:!1,action:d},w=o.to;if(w&&w.startsWith("#"))D(w,p);else{let N=o.from===le.current?o.to:o.from;s(fe=>fe.find(Ne=>Ne.type==="dm"&&Ne.name===N)?fe:[...fe,{type:"dm",name:N}]),D(N,p)}break}case"JOIN":{let p=`${o.from} has joined ${o.to}`;o.to&&D(o.to,{...f,text:p,system:!0}),o.to&&o.to.startsWith("#")&&G(o.to);break}case"PART":{let p=i?": "+i:"",w=`${o.from} has parted ${o.to}${p}`;o.to&&D(o.to,{...f,text:w,system:!0}),o.to&&o.to.startsWith("#")&&G(o.to);break}case"QUIT":{let p=i?": "+i:"",w=`${o.from} has quit${p}`;Y.current.forEach(N=>{N.type==="channel"&&D(N.name,{...f,text:w,system:!0})});break}case"NICK":{let p=Array.isArray(o.body)?o.body[0]:i,w=`${o.from} is now known as ${p}`;Y.current.forEach(N=>{N.type==="channel"&&D(N.name,{...f,text:w,system:!0})}),o.from===le.current&&p&&r(p),Y.current.forEach(N=>{N.type==="channel"&&G(N.name)});break}case"TOPIC":{let p=`${o.from} set the topic: ${i}`;o.to&&(D(o.to,{...f,text:p,system:!0}),A(w=>({...w,[o.to]:i})));break}case"332":{let p=Array.isArray(o.params)&&o.params.length>0?o.params[0]:o.to;p&&A(w=>({...w,[p]:i}));break}case"353":{let p=Array.isArray(o.params)&&o.params.length>1?o.params[1]:o.to;p&&i&&Ie(p,i);break}case"366":break;case"375":case"372":case"376":D("Server",{...f,text:i,system:!0});break;default:D("Server",{...f,text:i||o.command,system:!0})}},[D,G,Ie]);U(()=>{if(!e)return;let o=!0;return(async()=>{for(;o;)try{let f=new AbortController;W.current=f;let d=await M(`/messages?after=${q.current}&timeout=${It}`,{signal:f.signal});if(!o)break;if(V(!0),d.messages)for(let p of d.messages)ue(p);d.last_id>q.current&&(q.current=d.last_id)}catch(f){if(!o)break;if(f.name==="AbortError")continue;V(!1),await new Promise(d=>setTimeout(d,Pt))}})(),()=>{o=!1,W.current?.abort()}},[e,ue]),U(()=>{if(!e)return;let o=a[c];if(!o||o.type!=="channel")return;G(o.name);let i=setInterval(()=>G(o.name),Et);return()=>clearInterval(i)},[e,c,a,G]),U(()=>{Te.current?.scrollIntoView({behavior:"smooth"})},[v,c]),U(()=>{xe.current?.focus()},[c]),U(()=>{if(!e)return;let o=a[c];!o||o.type!=="channel"||M("/channels").then(i=>{let f=i.find(d=>d.name===o.name);f&&f.topic&&A(d=>({...d,[o.name]:f.topic}))}).catch(()=>{})},[e,c,a]);let _t=z(async o=>{r(o),t(!0),P("Server",`Connected as ${o}`);let i=JSON.parse(localStorage.getItem("neoirc_channels")||"[]");for(let f of i)try{await M("/messages",{method:"POST",body:JSON.stringify({command:"JOIN",to:f})}),s(d=>d.find(p=>p.type==="channel"&&p.name===f)?d:[...d,{type:"channel",name:f}])}catch{}},[P]),ct=async o=>{if(o){o=o.trim(),o.startsWith("#")||(o="#"+o);try{await M("/messages",{method:"POST",body:JSON.stringify({command:"JOIN",to:o})}),s(i=>i.find(f=>f.type==="channel"&&f.name===o)?i:[...i,{type:"channel",name:o}]),u(a.length);try{let i=await M(`/history?target=${encodeURIComponent(o)}&limit=50`);if(Array.isArray(i))for(let f of i)ue(f)}catch{}}catch(i){P("Server",`Failed to join ${o}: ${i.data?.error||"error"}`)}}},Pe=async(o,i)=>{try{let f={command:"PART",to:o};i&&(f.body=[i]),await M("/messages",{method:"POST",body:JSON.stringify(f)})}catch{}s(f=>f.filter(d=>!(d.type==="channel"&&d.name===o))),u(0)},it=o=>{let i=a[o];i.type==="channel"?Pe(i.name):i.type==="dm"&&(s(f=>f.filter((d,p)=>p!==o)),c>=o&&u(Math.max(0,c-1)))},Ee=o=>{s(f=>f.find(d=>d.type==="dm"&&d.name===o)?f:[...f,{type:"dm",name:o}]);let i=a.findIndex(f=>f.type==="dm"&&f.name===o);u(i>=0?i:a.length)},lt=async o=>{let i=o.split(" "),f=i[0].toLowerCase(),d=a[c];switch(f){case"/join":i[1]?ct(i[1]):P(d?.name||"Server","Usage: /join #channel");break;case"/part":{if(d?.type==="channel"){let p=i.slice(1).join(" ")||"";Pe(d.name,p)}else P(d?.name||"Server","Not in a channel");break}case"/msg":if(i[1]&&i.slice(2).join(" ")){let p=i[1],w=i.slice(2).join(" ");try{await M("/messages",{method:"POST",body:JSON.stringify({command:"PRIVMSG",to:p,body:[w]})}),Ee(p)}catch(N){P("Server",`DM failed: ${N.data?.error||"error"}`)}}else P(d?.name||"Server","Usage: /msg <nick> <message>");break;case"/me":if(d&&d.type!=="server"){let p=i.slice(1).join(" ");if(p)try{await M("/messages",{method:"POST",body:JSON.stringify({command:"PRIVMSG",to:d.name,body:[p],meta:{action:!0}})})}catch(w){P(d.name,`Action failed: ${w.data?.error||"error"}`)}else P(d.name,"Usage: /me <action>")}break;case"/nick":if(i[1])try{await M("/messages",{method:"POST",body:JSON.stringify({command:"NICK",body:[i[1]]})})}catch(p){P("Server",`Nick change failed: ${p.data?.error||"error"}`)}else P(d?.name||"Server","Usage: /nick <newnick>");break;case"/topic":if(d?.type==="channel"){let p=i.slice(1).join(" ");try{await M("/messages",{method:"POST",body:JSON.stringify({command:"TOPIC",to:d.name,body:[p]})})}catch(w){P(d.name,`Topic failed: ${w.data?.error||"error"}`)}}else P(d?.name||"Server","Not in a channel");break;case"/mode":if(d?.type==="channel"&&i.length>=2){let p=i[1].star
Line truncated
|
||||
var ie,w,Ue,pt,K,Ee,He,Re,De,he,de,pe,mt,Z={},Le=[],ht=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ce=Array.isArray;function W(e,t){for(var n in t)e[n]=t[n];return e}function ye(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function p(e,t,n){var o,a,s,c={};for(s in t)s=="key"?o=t[s]:s=="ref"?a=t[s]:c[s]=t[s];if(arguments.length>2&&(c.children=arguments.length>3?ie.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)c[s]===void 0&&(c[s]=e.defaultProps[s]);return oe(e,c,o,a,null)}function oe(e,t,n,o,a){var s={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++Ue,__i:-1,__u:0};return a==null&&w.vnode!=null&&w.vnode(s),s}function _e(e){return e.children}function se(e,t){this.props=e,this.context=t}function Y(e,t){if(t==null)return e.__?Y(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Y(e):null}function Fe(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return Fe(e)}}function Me(e){(!e.__d&&(e.__d=!0)&&K.push(e)&&!ae.__r++||Ee!=w.debounceRendering)&&((Ee=w.debounceRendering)||He)(ae)}function ae(){for(var e,t,n,o,a,s,c,_=1;K.length;)K.length>_&&K.sort(Re),e=K.shift(),_=K.length,e.__d&&(n=void 0,o=void 0,a=(o=(t=e).__v).__e,s=[],c=[],t.__P&&((n=W({},o)).__v=o.__v+1,w.vnode&&w.vnode(n),ve(t.__P,n,o,t.__n,t.__P.namespaceURI,32&o.__u?[a]:null,s,a??Y(o),!!(32&o.__u),c),n.__v=o.__v,n.__.__k[n.__i]=n,Je(s,n,c),o.__e=o.__=null,n.__e!=a&&Fe(n)));ae.__r=0}function We(e,t,n,o,a,s,c,_,h,u,b){var i,m,y,C,M,I,k,g=o&&o.__k||Le,U=t.length;for(h=yt(n,t,g,h,U),i=0;i<U;i++)(y=n.__k[i])!=null&&(m=y.__i==-1?Z:g[y.__i]||Z,y.__i=i,I=ve(e,y,m,a,s,c,_,h,u,b),C=y.__e,y.ref&&m.ref!=y.ref&&(m.ref&&be(m.ref,null,y),b.push(y.ref,y.__c||C,y)),M==null&&C!=null&&(M=C),(k=!!(4&y.__u))||m.__k===y.__k?h=je(y,h,e,k):typeof y.type=="function"&&I!==void 0?h=I:C&&(h=C.nextSibling),y.__u&=-7);return n.__e=M,h}function yt(e,t,n,o,a){var s,c,_,h,u,b=n.length,i=b,m=0;for(e.__k=new Array(a),s=0;s<a;s++)(c=t[s])!=null&&typeof c!="boolean"&&typeof c!="function"?(typeof c=="string"||typeof c=="number"||typeof c=="bigint"||c.constructor==String?c=e.__k[s]=oe(null,c,null,null,null):ce(c)?c=e.__k[s]=oe(_e,{children:c},null,null,null):c.constructor===void 0&&c.__b>0?c=e.__k[s]=oe(c.type,c.props,c.key,c.ref?c.ref:null,c.__v):e.__k[s]=c,h=s+m,c.__=e,c.__b=e.__b+1,_=null,(u=c.__i=vt(c,n,h,i))!=-1&&(i--,(_=n[u])&&(_.__u|=2)),_==null||_.__v==null?(u==-1&&(a>b?m--:a<b&&m++),typeof c.type!="function"&&(c.__u|=4)):u!=h&&(u==h-1?m--:u==h+1?m++:(u>h?m--:m++,c.__u|=4))):e.__k[s]=null;if(i)for(s=0;s<b;s++)(_=n[s])!=null&&(2&_.__u)==0&&(_.__e==o&&(o=Y(_)),Be(_,_));return o}function je(e,t,n,o){var a,s;if(typeof e.type=="function"){for(a=e.__k,s=0;a&&s<a.length;s++)a[s]&&(a[s].__=e,t=je(a[s],t,n,o));return t}e.__e!=t&&(o&&(t&&e.type&&!t.parentNode&&(t=Y(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function vt(e,t,n,o){var a,s,c,_=e.key,h=e.type,u=t[n],b=u!=null&&(2&u.__u)==0;if(u===null&&_==null||b&&_==u.key&&h==u.type)return n;if(o>(b?1:0)){for(a=n-1,s=n+1;a>=0||s<t.length;)if((u=t[c=a>=0?a--:s++])!=null&&(2&u.__u)==0&&_==u.key&&h==u.type)return c}return-1}function Oe(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||ht.test(t)?n:n+"px"}function re(e,t,n,o,a){var s,c;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||Oe(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||Oe(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(De,"$1")),c=t.toLowerCase(),t=c in e||t=="onFocusOut"||t=="onFocusIn"?c.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?o?n.u=o.u:(n.u=he,e.addEventListener(t,s?pe:de,s)):e.removeEventListener(t,s?pe:de,s);else{if(a=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function $e(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=he++;else if(t.t<n.u)return;return n(w.event?w.event(t):t)}}}function ve(e,t,n,o,a,s,c,_,h,u){var b,i,m,y,C,M,I,k,g,U,O,z,R,B,j,J,Q,P=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(h=!!(32&n.__u),s=[_=t.__e=n.__e]),(b=w.__b)&&b(t);e:if(typeof P=="function")try{if(k=t.props,g="prototype"in P&&P.prototype.render,U=(b=P.contextType)&&o[b.__c],O=b?U?U.props.value:b.__:o,n.__c?I=(i=t.__c=n.__c).__=i.__E:(g?t.__c=i=new P(k,O):(t.__c=i=new se(k,O),i.constructor=P,i.render=kt),U&&U.sub(i),i.state||(i.state={}),i.__n=o,m=i.Line truncated
|
||||
`):"",d={id:r.id,ts:r.ts,from:r.from,to:r.to,command:r.command};switch(r.command){case"PRIVMSG":case"NOTICE":{let f=l,v=!1;Pt(f)&&(f=Nt(f),v=!0);let S={...d,text:f,system:!1,isAction:v},G=r.to;if(G&&G.startsWith("#"))D(G,S);else{let H=r.from===ne.current?r.to:r.from;s(fe=>fe.find(Ne=>Ne.type==="dm"&&Ne.name===H)?fe:[...fe,{type:"dm",name:H}]),D(H,S)}break}case"JOIN":{let f=`${r.from} has joined ${r.to}`;r.to&&D(r.to,{...d,text:f,system:!0}),r.to&&r.to.startsWith("#")&&q(r.to);break}case"PART":{let f=l?" ("+l+")":"",v=`${r.from} has parted ${r.to}${f}`;r.to&&D(r.to,{...d,text:v,system:!0}),r.to&&r.to.startsWith("#")&&q(r.to);break}case"QUIT":{let f=l?" ("+l+")":"",v=`${r.from} has quit${f}`;P.current.forEach(S=>{S.type==="channel"&&D(S.name,{...d,text:v,system:!0})});break}case"NICK":{let f=Array.isArray(r.body)?r.body[0]:l,v=`${r.from} is now known as ${f}`;P.current.forEach(S=>{S.type==="channel"&&D(S.name,{...d,text:v,system:!0})}),r.from===ne.current&&f&&o(f),P.current.forEach(S=>{S.type==="channel"&&q(S.name)});break}case"TOPIC":{let f=`${r.from} has changed the topic to: ${l}`;r.to&&(D(r.to,{...d,text:f,system:!0}),y(v=>({...v,[r.to]:l})));break}case"353":{if(Array.isArray(r.params)&&r.params.length>=2&&r.body){let f=r.params[1],G=(Array.isArray(r.body)?r.body[0]:String(r.body)).split(/\s+/).filter(Boolean).map(H=>H.startsWith("@")?{nick:H.slice(1),mode:"o"}:H.startsWith("+")?{nick:H.slice(1),mode:"v"}:{nick:H,mode:""});i(H=>({...H,[f]:G}))}break}case"332":{if(Array.isArray(r.params)&&r.params.length>=1){let f=r.params[0],v=Array.isArray(r.body)?r.body[0]:l;v&&y(S=>({...S,[f]:v}))}break}case"375":case"372":case"376":D("Server",{...d,text:l,system:!0});break;default:l&&D("Server",{...d,text:l,system:!0})}},[D,q]);$(()=>{if(!e)return;let r=!0;return(async()=>{for(;r;)try{let d=new AbortController;Q.current=d;let f=await E(`/messages?after=${j.current}&timeout=${Tt}`,{signal:d.signal});if(!r)break;if(U(!0),f.messages)for(let v of f.messages)ue(v);f.last_id>j.current&&(j.current=f.last_id)}catch(d){if(!r)break;if(d.name==="AbortError")continue;U(!1),await new Promise(f=>setTimeout(f,xt))}})(),()=>{r=!1,Q.current?.abort()}},[e,ue]),$(()=>{if(!e)return;let r=a[c];if(!r||r.type!=="channel")return;q(r.name);let l=setInterval(()=>q(r.name),It);return()=>clearInterval(l)},[e,c,a,q]),$(()=>{xe.current?.scrollIntoView({behavior:"smooth"})},[h,c]),$(()=>{Ie.current?.focus()},[c]),$(()=>{if(!e)return;let r=a[c];!r||r.type!=="channel"||E("/channels").then(l=>{let d=l.find(f=>f.name===r.name);d&&d.topic&&y(f=>({...f,[r.name]:d.topic}))}).catch(()=>{})},[e,c,a]);let st=X(async r=>{o(r),t(!0),T("Server",`Connected as ${r}`);let l=JSON.parse(localStorage.getItem("neoirc_channels")||"[]");for(let d of l)try{await E("/messages",{method:"POST",body:JSON.stringify({command:"JOIN",to:d})}),s(f=>f.find(v=>v.type==="channel"&&v.name===d)?f:[...f,{type:"channel",name:d}])}catch{}},[T]),at=async r=>{if(r){r=r.trim(),r.startsWith("#")||(r="#"+r);try{await E("/messages",{method:"POST",body:JSON.stringify({command:"JOIN",to:r})}),s(d=>d.find(f=>f.type==="channel"&&f.name===r)?d:[...d,{type:"channel",name:r}]);let l=P.current.length;_(l);try{let d=await E(`/history?target=${encodeURIComponent(r)}&limit=50`);if(Array.isArray(d))for(let f of d)ue(f)}catch{}}catch(l){T("Server",`Failed to join ${r}: ${l.data?.error||"error"}`)}}},Ae=async(r,l)=>{try{await E("/messages",{method:"POST",body:JSON.stringify(l?{command:"PART",to:r,body:[l]}:{command:"PART",to:r})})}catch{}s(d=>d.filter(f=>!(f.type==="channel"&&f.name===r))),_(0)},it=r=>{let l=a[r];l.type==="channel"?Ae(l.name):l.type==="dm"&&(s(d=>d.filter((f,v)=>v!==r)),c>=r&&_(Math.max(0,c-1)))},Pe=r=>{if(r===ne.current)return;s(d=>d.find(f=>f.type==="dm"&&f.name===r)?d:[...d,{type:"dm",name:r}]);let l=a.findIndex(d=>d.type==="dm"&&d.name===r);_(l>=0?l:a.length)},ct=async r=>{let l=r.split(" "),d=l[0].toLowerCase(),f=a[c];switch(d){case"/join":{l[1]?at(l[1]):T("Server","Usage: /join #channel");break}case"/part":{if(f.type==="channel"){let v=l.slice(1).join(" ")||void 0;Ae(f.name,v)}else T("Server","You are not in a channel");break}case"/msg":{if(l[1]&&l.slice(2).join(" ")){let v=l[1],S=l.slice(2).join(" ");try{await E("/messages",{method:"POST",body:JSON.stringify({command:"PRIVMSG",to:v,body:[S]})}),Pe(v)}catch(G){T("Server",`Message failed: ${G.data?.error||"error"}`)}}else T("Server","Usage: /msg <nick> <message>");break}case"/me":{if(f.type==="server"){T("Server","Cannot use /me in server window");break}let v=l.slice(1).join(" ");if(v)try{await E("/messages",{method:"POST",body:JSON.stringify({command:"PRIVMSG",to:f.name,body:[Ce+v+Te]})})}catch(S){T(f.name,`Action failed: ${S.data?.error||"error"}`)}else T("Server","Usage: /me <action>");break}case"/nick":{if(l[1])try{await E("/messages",{method:"POST",body:JSON.stringify({command:"NICK",body:[l[1]]})})}catch(v){T("Server",`Nick change failed: ${v.data?.error||"error"}`)}else T("Server","Usage: /nick <newnick>");break}case"/topic":{i
Line truncated
|
||||
Vendored
+279
-244
@@ -6,218 +6,282 @@
|
||||
|
||||
:root {
|
||||
--bg: #0a0e14;
|
||||
--bg-secondary: #0d1117;
|
||||
--bg-input: #161b22;
|
||||
--bg-highlight: #1a2030;
|
||||
--bg-panel: #0d1117;
|
||||
--bg-input: #0d1117;
|
||||
--bg-tab: #161b22;
|
||||
--bg-tab-active: #0d1117;
|
||||
--bg-topic: #0d1117;
|
||||
--text: #c9d1d9;
|
||||
--text-muted: #6e7681;
|
||||
--text-dim: #6e7681;
|
||||
--text-bright: #e6edf3;
|
||||
--accent: #58a6ff;
|
||||
--accent-dim: #1f6feb;
|
||||
--border: #21262d;
|
||||
--nick: #79c0ff;
|
||||
--timestamp: #484f58;
|
||||
--tab-active: #58a6ff;
|
||||
--tab-bg: #0d1117;
|
||||
--tab-hover: #161b22;
|
||||
--topic-bg: #0d1117;
|
||||
--unread-bg: #da3633;
|
||||
--system: #7d8590;
|
||||
--action: #d2a8ff;
|
||||
--warn: #d29922;
|
||||
--op-color: #f0883e;
|
||||
--voice-color: #3fb950;
|
||||
--action-color: #bc8cff;
|
||||
--system-color: #484f58;
|
||||
--error: #f85149;
|
||||
--unread: #f0883e;
|
||||
--nick-brackets: #6e7681;
|
||||
--timestamp: #484f58;
|
||||
--input-bg: #161b22;
|
||||
--prompt: #3fb950;
|
||||
--tab-indicator: #58a6ff;
|
||||
--user-list-bg: #0d1117;
|
||||
--user-list-header: #484f58;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
height: 100%;
|
||||
font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New',
|
||||
Courier, monospace;
|
||||
font-family: "JetBrains Mono", "Cascadia Code", "Fira Code", "SF Mono",
|
||||
"Consolas", "Liberation Mono", "Courier New", monospace;
|
||||
font-size: 13px;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Login screen */
|
||||
/* ============================================
|
||||
Login Screen
|
||||
============================================ */
|
||||
|
||||
.login-screen {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
gap: 16px;
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.login-screen h1 {
|
||||
.login-box {
|
||||
text-align: center;
|
||||
max-width: 360px;
|
||||
width: 100%;
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.login-box h1 {
|
||||
color: var(--accent);
|
||||
font-size: 2em;
|
||||
font-size: 1.8em;
|
||||
margin-bottom: 16px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.login-screen input {
|
||||
padding: 10px 16px;
|
||||
font-size: 16px;
|
||||
.login-box .motd {
|
||||
color: var(--text-dim);
|
||||
font-size: 12px;
|
||||
margin-bottom: 20px;
|
||||
text-align: left;
|
||||
white-space: pre-wrap;
|
||||
font-family: inherit;
|
||||
background: var(--bg-input);
|
||||
border-left: 2px solid var(--border);
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.login-box form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.login-box label {
|
||||
color: var(--text-dim);
|
||||
text-align: left;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.login-box input {
|
||||
padding: 8px 12px;
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
background: var(--input-bg);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text);
|
||||
border-radius: 4px;
|
||||
width: 280px;
|
||||
color: var(--text-bright);
|
||||
border-radius: 3px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.login-screen button {
|
||||
padding: 10px 24px;
|
||||
font-size: 16px;
|
||||
.login-box input:focus {
|
||||
border-color: var(--accent-dim);
|
||||
}
|
||||
|
||||
.login-box button {
|
||||
padding: 8px 16px;
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
background: var(--accent-dim);
|
||||
border: none;
|
||||
color: white;
|
||||
border-radius: 4px;
|
||||
color: var(--text-bright);
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.login-screen button:hover {
|
||||
.login-box button:hover {
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.login-screen .error {
|
||||
color: var(--unread-bg);
|
||||
.login-box .error {
|
||||
color: var(--error);
|
||||
font-size: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.login-screen .motd {
|
||||
color: var(--text-muted);
|
||||
max-width: 400px;
|
||||
text-align: center;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
/* ============================================
|
||||
IRC App Layout
|
||||
============================================ */
|
||||
|
||||
/* Main layout */
|
||||
.app {
|
||||
.irc-app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Tab bar */
|
||||
/* ============================================
|
||||
Tab Bar
|
||||
============================================ */
|
||||
|
||||
.tab-bar {
|
||||
display: flex;
|
||||
background: var(--bg-secondary);
|
||||
background: var(--bg-tab);
|
||||
border-bottom: 1px solid var(--border);
|
||||
overflow-x: auto;
|
||||
flex-shrink: 0;
|
||||
height: 32px;
|
||||
align-items: stretch;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.tab-bar::-webkit-scrollbar {
|
||||
height: 2px;
|
||||
.tabs {
|
||||
display: flex;
|
||||
overflow-x: auto;
|
||||
flex: 1;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.tab-bar::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
.tabs::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tab {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
padding: 0 12px;
|
||||
cursor: pointer;
|
||||
border-bottom: 2px solid transparent;
|
||||
color: var(--text-dim);
|
||||
white-space: nowrap;
|
||||
color: var(--text-muted);
|
||||
user-select: none;
|
||||
border-right: 1px solid var(--border);
|
||||
font-size: 12px;
|
||||
gap: 6px;
|
||||
transition:
|
||||
background 0.1s,
|
||||
color 0.1s;
|
||||
gap: 4px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab:hover {
|
||||
background: var(--tab-hover);
|
||||
color: var(--text);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
color: var(--text);
|
||||
border-bottom-color: var(--tab-active);
|
||||
background: var(--bg-highlight);
|
||||
color: var(--text-bright);
|
||||
background: var(--bg-tab-active);
|
||||
border-bottom: 2px solid var(--tab-indicator);
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
.tab.server {
|
||||
.tab.has-unread .tab-label {
|
||||
color: var(--unread);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tab .tab-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.tab .close-btn {
|
||||
color: var(--text-muted);
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tab .close-btn:hover {
|
||||
color: var(--unread-bg);
|
||||
}
|
||||
|
||||
.tab .unread-badge {
|
||||
display: inline-block;
|
||||
background: var(--unread-bg);
|
||||
color: white;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
padding: 0 5px;
|
||||
border-radius: 8px;
|
||||
min-width: 16px;
|
||||
text-align: center;
|
||||
line-height: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Connection status */
|
||||
.connection-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 12px;
|
||||
background: var(--warn);
|
||||
color: var(--bg);
|
||||
.tab .unread-count {
|
||||
color: var(--unread);
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Topic bar */
|
||||
.topic-bar {
|
||||
padding: 4px 12px;
|
||||
background: var(--topic-bg);
|
||||
border-bottom: 1px solid var(--border);
|
||||
color: var(--text-muted);
|
||||
.tab-close {
|
||||
color: var(--text-dim);
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.tab-close:hover {
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.status-area {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0 12px;
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.topic-bar .topic-label {
|
||||
.status-nick {
|
||||
color: var(--accent);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Content area */
|
||||
.content {
|
||||
.status-warn {
|
||||
color: var(--warn);
|
||||
animation: blink 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Topic Bar
|
||||
============================================ */
|
||||
|
||||
.topic-bar {
|
||||
padding: 4px 12px;
|
||||
background: var(--bg-topic);
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex-shrink: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.topic-label {
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.topic-text {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Main Content Area
|
||||
============================================ */
|
||||
|
||||
.main-area {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* Messages */
|
||||
.messages-pane {
|
||||
/* ============================================
|
||||
Messages Panel
|
||||
============================================ */
|
||||
|
||||
.messages-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -225,207 +289,178 @@ body,
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.messages {
|
||||
.messages-scroll {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px 0;
|
||||
padding: 4px 8px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border) transparent;
|
||||
}
|
||||
|
||||
.messages::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
.messages-scroll::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.messages::-webkit-scrollbar-thumb {
|
||||
.messages-scroll::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.messages-scroll::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
border-radius: 3px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Message Lines
|
||||
============================================ */
|
||||
|
||||
.message {
|
||||
padding: 1px 12px;
|
||||
line-height: 1.5;
|
||||
padding: 1px 0;
|
||||
line-height: 1.4;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.message:hover {
|
||||
background: var(--bg-highlight);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.message .timestamp {
|
||||
color: var(--timestamp);
|
||||
font-size: 11px;
|
||||
margin-right: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.message .nick {
|
||||
font-weight: bold;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.message .nick::before {
|
||||
content: '<';
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.message .nick::after {
|
||||
content: '>';
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.message.system {
|
||||
color: var(--system-color);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.message.system .timestamp {
|
||||
color: var(--timestamp);
|
||||
}
|
||||
|
||||
.message.system .content::before {
|
||||
content: '*** ';
|
||||
}
|
||||
|
||||
.message.action {
|
||||
color: var(--action-color);
|
||||
}
|
||||
|
||||
.message.action .timestamp {
|
||||
color: var(--timestamp);
|
||||
}
|
||||
|
||||
.message.action .action-nick {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Input bar — full width at bottom */
|
||||
.input-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-top: 1px solid var(--border);
|
||||
background: var(--bg-secondary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.input-bar .input-nick {
|
||||
padding: 0 8px 0 12px;
|
||||
color: var(--accent);
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.input-bar .input-nick::after {
|
||||
content: '>';
|
||||
color: var(--text-muted);
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
.input-bar input {
|
||||
flex: 1;
|
||||
padding: 8px 8px;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
.message .content {
|
||||
color: var(--text);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.input-bar input::placeholder {
|
||||
color: var(--text-muted);
|
||||
/* System messages (joins, parts, quits, etc.) */
|
||||
.system-message {
|
||||
color: var(--system);
|
||||
}
|
||||
|
||||
/* User list */
|
||||
.system-message .system-text {
|
||||
color: var(--system);
|
||||
}
|
||||
|
||||
/* /me action messages */
|
||||
.action-message .action-text {
|
||||
color: var(--action);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
User List (Right Panel)
|
||||
============================================ */
|
||||
|
||||
.user-list {
|
||||
width: 170px;
|
||||
background: var(--bg-secondary);
|
||||
width: 160px;
|
||||
background: var(--user-list-bg);
|
||||
border-left: 1px solid var(--border);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.user-list-header {
|
||||
padding: 6px 10px;
|
||||
color: var(--text-muted);
|
||||
color: var(--user-list-header);
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-weight: bold;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-list-entries {
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
padding: 4px 0;
|
||||
flex: 1;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border) transparent;
|
||||
}
|
||||
|
||||
.user-list-entries::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
.user-list-entries::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
}
|
||||
|
||||
.user-list .user {
|
||||
.nick-entry {
|
||||
padding: 2px 10px;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--text);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.user-list .user:hover {
|
||||
background: var(--tab-hover);
|
||||
.nick-entry:hover {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
.user-list .user.op {
|
||||
color: var(--op-color);
|
||||
.nick-prefix {
|
||||
color: var(--text-dim);
|
||||
display: inline-block;
|
||||
width: 1ch;
|
||||
text-align: right;
|
||||
margin-right: 1px;
|
||||
}
|
||||
|
||||
.user-list .user.voice {
|
||||
color: var(--voice-color);
|
||||
.nick-name {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* Server tab messages */
|
||||
.server-messages {
|
||||
color: var(--text-muted);
|
||||
padding: 8px 12px;
|
||||
white-space: pre-wrap;
|
||||
overflow-y: auto;
|
||||
/* ============================================
|
||||
Input Line (Bottom)
|
||||
============================================ */
|
||||
|
||||
.input-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: var(--input-bg);
|
||||
border-top: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
height: 36px;
|
||||
padding: 0 8px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.input-prompt {
|
||||
color: var(--prompt);
|
||||
font-size: 13px;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.input-line input {
|
||||
flex: 1;
|
||||
padding: 4px 0;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-bright);
|
||||
outline: none;
|
||||
caret-color: var(--accent);
|
||||
}
|
||||
|
||||
.server-messages .message {
|
||||
padding: 1px 0;
|
||||
.input-line input::placeholder {
|
||||
color: var(--text-dim);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.server-messages .message:hover {
|
||||
background: var(--bg-highlight);
|
||||
}
|
||||
/* ============================================
|
||||
Responsive
|
||||
============================================ */
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 600px) {
|
||||
.user-list {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 5px 8px;
|
||||
padding: 0 8px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.input-bar .input-nick {
|
||||
padding-left: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.input-bar input {
|
||||
.input-prompt {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
+438
-367
File diff suppressed because it is too large.
Load diff
+279
-244
@@ -6,218 +6,282 @@
|
||||
|
||||
:root {
|
||||
--bg: #0a0e14;
|
||||
--bg-secondary: #0d1117;
|
||||
--bg-input: #161b22;
|
||||
--bg-highlight: #1a2030;
|
||||
--bg-panel: #0d1117;
|
||||
--bg-input: #0d1117;
|
||||
--bg-tab: #161b22;
|
||||
--bg-tab-active: #0d1117;
|
||||
--bg-topic: #0d1117;
|
||||
--text: #c9d1d9;
|
||||
--text-muted: #6e7681;
|
||||
--text-dim: #6e7681;
|
||||
--text-bright: #e6edf3;
|
||||
--accent: #58a6ff;
|
||||
--accent-dim: #1f6feb;
|
||||
--border: #21262d;
|
||||
--nick: #79c0ff;
|
||||
--timestamp: #484f58;
|
||||
--tab-active: #58a6ff;
|
||||
--tab-bg: #0d1117;
|
||||
--tab-hover: #161b22;
|
||||
--topic-bg: #0d1117;
|
||||
--unread-bg: #da3633;
|
||||
--system: #7d8590;
|
||||
--action: #d2a8ff;
|
||||
--warn: #d29922;
|
||||
--op-color: #f0883e;
|
||||
--voice-color: #3fb950;
|
||||
--action-color: #bc8cff;
|
||||
--system-color: #484f58;
|
||||
--error: #f85149;
|
||||
--unread: #f0883e;
|
||||
--nick-brackets: #6e7681;
|
||||
--timestamp: #484f58;
|
||||
--input-bg: #161b22;
|
||||
--prompt: #3fb950;
|
||||
--tab-indicator: #58a6ff;
|
||||
--user-list-bg: #0d1117;
|
||||
--user-list-header: #484f58;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
height: 100%;
|
||||
font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New',
|
||||
Courier, monospace;
|
||||
font-family: "JetBrains Mono", "Cascadia Code", "Fira Code", "SF Mono",
|
||||
"Consolas", "Liberation Mono", "Courier New", monospace;
|
||||
font-size: 13px;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Login screen */
|
||||
/* ============================================
|
||||
Login Screen
|
||||
============================================ */
|
||||
|
||||
.login-screen {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
gap: 16px;
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.login-screen h1 {
|
||||
.login-box {
|
||||
text-align: center;
|
||||
max-width: 360px;
|
||||
width: 100%;
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.login-box h1 {
|
||||
color: var(--accent);
|
||||
font-size: 2em;
|
||||
font-size: 1.8em;
|
||||
margin-bottom: 16px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.login-screen input {
|
||||
padding: 10px 16px;
|
||||
font-size: 16px;
|
||||
.login-box .motd {
|
||||
color: var(--text-dim);
|
||||
font-size: 12px;
|
||||
margin-bottom: 20px;
|
||||
text-align: left;
|
||||
white-space: pre-wrap;
|
||||
font-family: inherit;
|
||||
background: var(--bg-input);
|
||||
border-left: 2px solid var(--border);
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.login-box form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.login-box label {
|
||||
color: var(--text-dim);
|
||||
text-align: left;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.login-box input {
|
||||
padding: 8px 12px;
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
background: var(--input-bg);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text);
|
||||
border-radius: 4px;
|
||||
width: 280px;
|
||||
color: var(--text-bright);
|
||||
border-radius: 3px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.login-screen button {
|
||||
padding: 10px 24px;
|
||||
font-size: 16px;
|
||||
.login-box input:focus {
|
||||
border-color: var(--accent-dim);
|
||||
}
|
||||
|
||||
.login-box button {
|
||||
padding: 8px 16px;
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
background: var(--accent-dim);
|
||||
border: none;
|
||||
color: white;
|
||||
border-radius: 4px;
|
||||
color: var(--text-bright);
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.login-screen button:hover {
|
||||
.login-box button:hover {
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.login-screen .error {
|
||||
color: var(--unread-bg);
|
||||
.login-box .error {
|
||||
color: var(--error);
|
||||
font-size: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.login-screen .motd {
|
||||
color: var(--text-muted);
|
||||
max-width: 400px;
|
||||
text-align: center;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
/* ============================================
|
||||
IRC App Layout
|
||||
============================================ */
|
||||
|
||||
/* Main layout */
|
||||
.app {
|
||||
.irc-app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Tab bar */
|
||||
/* ============================================
|
||||
Tab Bar
|
||||
============================================ */
|
||||
|
||||
.tab-bar {
|
||||
display: flex;
|
||||
background: var(--bg-secondary);
|
||||
background: var(--bg-tab);
|
||||
border-bottom: 1px solid var(--border);
|
||||
overflow-x: auto;
|
||||
flex-shrink: 0;
|
||||
height: 32px;
|
||||
align-items: stretch;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.tab-bar::-webkit-scrollbar {
|
||||
height: 2px;
|
||||
.tabs {
|
||||
display: flex;
|
||||
overflow-x: auto;
|
||||
flex: 1;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.tab-bar::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
.tabs::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tab {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
padding: 0 12px;
|
||||
cursor: pointer;
|
||||
border-bottom: 2px solid transparent;
|
||||
color: var(--text-dim);
|
||||
white-space: nowrap;
|
||||
color: var(--text-muted);
|
||||
user-select: none;
|
||||
border-right: 1px solid var(--border);
|
||||
font-size: 12px;
|
||||
gap: 6px;
|
||||
transition:
|
||||
background 0.1s,
|
||||
color 0.1s;
|
||||
gap: 4px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab:hover {
|
||||
background: var(--tab-hover);
|
||||
color: var(--text);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
color: var(--text);
|
||||
border-bottom-color: var(--tab-active);
|
||||
background: var(--bg-highlight);
|
||||
color: var(--text-bright);
|
||||
background: var(--bg-tab-active);
|
||||
border-bottom: 2px solid var(--tab-indicator);
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
.tab.server {
|
||||
.tab.has-unread .tab-label {
|
||||
color: var(--unread);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tab .tab-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.tab .close-btn {
|
||||
color: var(--text-muted);
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tab .close-btn:hover {
|
||||
color: var(--unread-bg);
|
||||
}
|
||||
|
||||
.tab .unread-badge {
|
||||
display: inline-block;
|
||||
background: var(--unread-bg);
|
||||
color: white;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
padding: 0 5px;
|
||||
border-radius: 8px;
|
||||
min-width: 16px;
|
||||
text-align: center;
|
||||
line-height: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Connection status */
|
||||
.connection-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 12px;
|
||||
background: var(--warn);
|
||||
color: var(--bg);
|
||||
.tab .unread-count {
|
||||
color: var(--unread);
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Topic bar */
|
||||
.topic-bar {
|
||||
padding: 4px 12px;
|
||||
background: var(--topic-bg);
|
||||
border-bottom: 1px solid var(--border);
|
||||
color: var(--text-muted);
|
||||
.tab-close {
|
||||
color: var(--text-dim);
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.tab-close:hover {
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.status-area {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0 12px;
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.topic-bar .topic-label {
|
||||
.status-nick {
|
||||
color: var(--accent);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Content area */
|
||||
.content {
|
||||
.status-warn {
|
||||
color: var(--warn);
|
||||
animation: blink 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Topic Bar
|
||||
============================================ */
|
||||
|
||||
.topic-bar {
|
||||
padding: 4px 12px;
|
||||
background: var(--bg-topic);
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex-shrink: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.topic-label {
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.topic-text {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Main Content Area
|
||||
============================================ */
|
||||
|
||||
.main-area {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* Messages */
|
||||
.messages-pane {
|
||||
/* ============================================
|
||||
Messages Panel
|
||||
============================================ */
|
||||
|
||||
.messages-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -225,207 +289,178 @@ body,
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.messages {
|
||||
.messages-scroll {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px 0;
|
||||
padding: 4px 8px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border) transparent;
|
||||
}
|
||||
|
||||
.messages::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
.messages-scroll::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.messages::-webkit-scrollbar-thumb {
|
||||
.messages-scroll::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.messages-scroll::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
border-radius: 3px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Message Lines
|
||||
============================================ */
|
||||
|
||||
.message {
|
||||
padding: 1px 12px;
|
||||
line-height: 1.5;
|
||||
padding: 1px 0;
|
||||
line-height: 1.4;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.message:hover {
|
||||
background: var(--bg-highlight);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.message .timestamp {
|
||||
color: var(--timestamp);
|
||||
font-size: 11px;
|
||||
margin-right: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.message .nick {
|
||||
font-weight: bold;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.message .nick::before {
|
||||
content: '<';
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.message .nick::after {
|
||||
content: '>';
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.message.system {
|
||||
color: var(--system-color);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.message.system .timestamp {
|
||||
color: var(--timestamp);
|
||||
}
|
||||
|
||||
.message.system .content::before {
|
||||
content: '*** ';
|
||||
}
|
||||
|
||||
.message.action {
|
||||
color: var(--action-color);
|
||||
}
|
||||
|
||||
.message.action .timestamp {
|
||||
color: var(--timestamp);
|
||||
}
|
||||
|
||||
.message.action .action-nick {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Input bar — full width at bottom */
|
||||
.input-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-top: 1px solid var(--border);
|
||||
background: var(--bg-secondary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.input-bar .input-nick {
|
||||
padding: 0 8px 0 12px;
|
||||
color: var(--accent);
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.input-bar .input-nick::after {
|
||||
content: '>';
|
||||
color: var(--text-muted);
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
.input-bar input {
|
||||
flex: 1;
|
||||
padding: 8px 8px;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
.message .content {
|
||||
color: var(--text);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.input-bar input::placeholder {
|
||||
color: var(--text-muted);
|
||||
/* System messages (joins, parts, quits, etc.) */
|
||||
.system-message {
|
||||
color: var(--system);
|
||||
}
|
||||
|
||||
/* User list */
|
||||
.system-message .system-text {
|
||||
color: var(--system);
|
||||
}
|
||||
|
||||
/* /me action messages */
|
||||
.action-message .action-text {
|
||||
color: var(--action);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
User List (Right Panel)
|
||||
============================================ */
|
||||
|
||||
.user-list {
|
||||
width: 170px;
|
||||
background: var(--bg-secondary);
|
||||
width: 160px;
|
||||
background: var(--user-list-bg);
|
||||
border-left: 1px solid var(--border);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.user-list-header {
|
||||
padding: 6px 10px;
|
||||
color: var(--text-muted);
|
||||
color: var(--user-list-header);
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-weight: bold;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-list-entries {
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
padding: 4px 0;
|
||||
flex: 1;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border) transparent;
|
||||
}
|
||||
|
||||
.user-list-entries::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
.user-list-entries::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
}
|
||||
|
||||
.user-list .user {
|
||||
.nick-entry {
|
||||
padding: 2px 10px;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--text);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.user-list .user:hover {
|
||||
background: var(--tab-hover);
|
||||
.nick-entry:hover {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
.user-list .user.op {
|
||||
color: var(--op-color);
|
||||
.nick-prefix {
|
||||
color: var(--text-dim);
|
||||
display: inline-block;
|
||||
width: 1ch;
|
||||
text-align: right;
|
||||
margin-right: 1px;
|
||||
}
|
||||
|
||||
.user-list .user.voice {
|
||||
color: var(--voice-color);
|
||||
.nick-name {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* Server tab messages */
|
||||
.server-messages {
|
||||
color: var(--text-muted);
|
||||
padding: 8px 12px;
|
||||
white-space: pre-wrap;
|
||||
overflow-y: auto;
|
||||
/* ============================================
|
||||
Input Line (Bottom)
|
||||
============================================ */
|
||||
|
||||
.input-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: var(--input-bg);
|
||||
border-top: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
height: 36px;
|
||||
padding: 0 8px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.input-prompt {
|
||||
color: var(--prompt);
|
||||
font-size: 13px;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.input-line input {
|
||||
flex: 1;
|
||||
padding: 4px 0;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-bright);
|
||||
outline: none;
|
||||
caret-color: var(--accent);
|
||||
}
|
||||
|
||||
.server-messages .message {
|
||||
padding: 1px 0;
|
||||
.input-line input::placeholder {
|
||||
color: var(--text-dim);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.server-messages .message:hover {
|
||||
background: var(--bg-highlight);
|
||||
}
|
||||
/* ============================================
|
||||
Responsive
|
||||
============================================ */
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 600px) {
|
||||
.user-list {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 5px 8px;
|
||||
padding: 0 8px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.input-bar .input-nick {
|
||||
padding-left: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.input-bar input {
|
||||
.input-prompt {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user