-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
continent.go
126 lines (121 loc) · 2.48 KB
/
continent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package main
import (
"fmt"
"net/http"
"strings"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
func (a *App) DispatchCommand(text string) string {
a.logger.Debug("dispatchcommand", "text", text)
words := strings.Fields(text)
if len(words) < 1 {
return a.Post(text)
}
action := words[0]
switch action {
case "/help":
{
if len(words) < 2 {
OpenURL("https://github.com/kakakaya/mazesoba-continent/blob/main/README.md")
}
switch words[1] {
case "config":
{
OpenURL("https://github.com/kakakaya/mazesoba-continent/tree/main/docs/CONFIG.md")
}
case "command":
{
OpenURL("https://github.com/kakakaya/mazesoba-continent/tree/main/docs/SLASH_COMMAND.md")
}
default:
{
OpenURL("https://github.com/kakakaya/mazesoba-continent/blob/main/README.md")
}
}
return ""
}
case "/open":
{
if len(words) < 2 {
return "🍜「何を開く?アジ?」"
}
switch words[1] {
case "config":
{
a.OpenConfigDirectory()
}
case "log":
{
a.OpenLogDirectory()
}
case "profile":
{
handle_or_did := words[2]
OpenURL(fmt.Sprintf("https://bsky.app/profile/%s", handle_or_did))
}
case "search", "s":
{
if len(words) < 3 {
return "🍜「検索ワードを指定してね」"
}
req, err := http.NewRequest("GET", "https://bsky.app/search", nil)
if err != nil {
a.logger.Warn("error making HTTP request", "error", err)
return ""
}
q := req.URL.Query()
q.Add("q", strings.Join(words[2:], " "))
req.URL.RawQuery = q.Encode()
OpenURL(req.URL.String())
}
default:
{
OpenURL(words[1]) // NOTE: TBC
}
}
return ""
}
case "/post":
{
if len(words) < 2 {
return "🍜「サブコマンドを指定してね。 /post version とか」"
}
switch words[1] {
case "chikuwa", "ckw":
{
return a.Chikuwa("ちくわ。")
}
case "earthquake", "eq":
{
return a.Chikuwa("地震だ!")
}
case "version", "ver":
{
return a.Chikuwa(fmt.Sprintf("まぜそば大陸バージョン%sが浮上中", Version))
}
}
}
case "/quit":
{
runtime.Quit(a.ctx)
}
case "/mzsb": // hidden functions
{
if len(words) < 2 {
return ""
}
switch words[1] {
case "egosearch", "egs":
{
OpenURL("https://bsky.app/search?q=%E3%81%BE%E3%81%9C%E3%81%9D%E3%81%B0%E5%A4%A7%E9%99%B8")
}
}
return ""
}
default:
{
return a.Post(text)
}
}
return ""
}