commit 64a7907
delthas
·
2024-10-05 15:37:49 +0000 UTC
parent 752eb5c
Add notice about using bouncers with senpai
3 files changed,
+53,
-4
M
app.go
+18,
-0
1@@ -138,6 +138,8 @@ type App struct {
2 imageOverlay bool
3
4 uploadingProgress *float64
5+
6+ shownBouncerNotice bool
7 }
8
9 func NewApp(cfg Config) (app *App, err error) {
10@@ -1211,6 +1213,22 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
11 Head: "--",
12 Body: ui.PlainString(body),
13 })
14+ if !app.shownBouncerNotice && !s.IsBouncer() {
15+ app.shownBouncerNotice = true
16+ for _, line := range []string{
17+ "senpai appears to be directly connected to an IRC server, rather than to an \x02IRC bouncer\x02. This is supported, but provides a limited IRC experience.",
18+ "In order to connect to multiple networks, keep message history, search through your messages, and upload files, use an \x02IRC bouncer\x02 and point senpai to the bouncer.",
19+ "Most senpai users use senpai with the IRC bouncer software \x02soju\x02.",
20+ "* You can self-host \x02soju\x02 yourself (it is free and open-source): https://soju.im/",
21+ "* You can also use a commercial hosted bouncer (uses \x02soju\x02 underneath), endorsed by senpai: \x02https://irctoday.com/\x02",
22+ } {
23+ app.addStatusLine(netID, ui.Line{
24+ At: msg.TimeOrNow(),
25+ Head: "Bouncer --",
26+ Body: ui.IRCString(line),
27+ })
28+ }
29+ }
30 for target := range app.monitor[s.NetID()] {
31 // TODO: batch MONITOR +
32 s.MonitorAdd(target)
+25,
-4
1@@ -7,6 +7,7 @@ import (
2 "math/rand"
3 "os"
4 "os/signal"
5+ "os/user"
6 "path"
7 "strings"
8 "syscall"
9@@ -45,8 +46,15 @@ func main() {
10 tls := true
11 var nick, password string
12 fmt.Fprintf(os.Stderr, "The configuration file at %q was not found.\n", configPath)
13- fmt.Fprintf(os.Stderr, "Configuration assistant: senpai will create a configuration file for you.\n")
14- fmt.Fprintf(os.Stderr, "Configuration assistant: Enter your server host (examples: example.com, localhost, 1.2.3.4): ")
15+ fmt.Fprintf(os.Stderr, "Configuration assistant: senpai will create a configuration file for you.\n\n")
16+ fmt.Fprintf(os.Stderr, "Important senpai information:\n")
17+ fmt.Fprintf(os.Stderr, "* senpai is able to connect to at most 1 server at a time.\n")
18+ fmt.Fprintf(os.Stderr, "* In order to connect to multiple networks, keep message history, search through your messages, and upload files, use an \x1B[1mIRC bouncer\x1B[0m and point senpai to the bouncer.\n")
19+ fmt.Fprintf(os.Stderr, "* Most senpai users use senpai with the IRC bouncer software \x1B[1msoju\x1B[0m.\n")
20+ fmt.Fprintf(os.Stderr, "** You can self-host \x1B[1msoju\x1B[0m yourself (it is free and open-source): https://soju.im/\n")
21+ fmt.Fprintf(os.Stderr, "** You can also use a commercial hosted bouncer (uses \x1B[1msoju\x1B[0m underneath), endorsed by senpai: \x1B[1;4mhttps://irctoday.com/\x1B[0m\n\n")
22+ fmt.Fprintf(os.Stderr, "Feel free to connect to your server now and configure a bouncer later to enable additional features.\n\n")
23+ fmt.Fprintf(os.Stderr, "Configuration assistant: Enter your server host (examples: irc.libera.chat, irctoday.com): ")
24 for host == "" {
25 fmt.Scanln(&host)
26 }
27@@ -69,10 +77,23 @@ func main() {
28 }
29 break
30 }
31- fmt.Fprintf(os.Stderr, "Configuration assistant: Enter your nickname: ")
32- for nick == "" {
33+ var defaultNick string
34+ if u, err := user.Current(); err == nil {
35+ defaultNick = u.Username
36+ if _, name, ok := strings.Cut(defaultNick, "\\"); ok {
37+ defaultNick = name
38+ }
39+ fmt.Fprintf(os.Stderr, "Configuration assistant: Enter your nickname [optional, default: %v]: ", defaultNick)
40+ } else {
41+ fmt.Fprintf(os.Stderr, "Configuration assistant: Enter your nickname: ")
42+ }
43+ fmt.Scanln(&nick)
44+ for defaultNick == "" && nick == "" {
45 fmt.Scanln(&nick)
46 }
47+ if nick == "" {
48+ nick = defaultNick
49+ }
50 fmt.Fprintf(os.Stderr, "Configuration assistant: Enter your password (only enter if you already have an account) [optional]: ")
51 fmt.Scanln(&password)
52
+10,
-0
1@@ -228,6 +228,16 @@ func (s *Session) HasCapability(capability string) bool {
2 return ok
3 }
4
5+func (s *Session) IsBouncer() bool {
6+ if s.HasCapability("soju.im/bouncer-networks") { // soju-compatible
7+ return true
8+ }
9+ if s.defaultPrefix != nil && s.defaultPrefix.Name == "irc.znc.in" { // ZNC
10+ return true
11+ }
12+ return false
13+}
14+
15 // BouncerService returns the optional nick of the bouncer service user.
16 func (s *Session) BouncerService() string {
17 switch s.serverName {