Skip to content

Commit

Permalink
Merge pull request #50 from PicoSushi/hotfix/issue-49-use-url-api
Browse files Browse the repository at this point in the history
Use BrowserOpenURL and delete OpenURL
  • Loading branch information
kakakaya authored Mar 2, 2024
2 parents a040025 + b6ba622 commit 9b7a6bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
19 changes: 0 additions & 19 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"log/slog"
"net/http"
"os"
"os/exec"
goruntime "runtime"
"strings"
"time"

Expand Down Expand Up @@ -166,23 +164,6 @@ func (a *App) OpenLogDirectory() error {
return openDirectory(f)
}

func OpenURL(url string) error {
var cmd string
var args []string

switch goruntime.GOOS {
case "windows":
cmd = "cmd"
args = []string{"/c", "start"}
case "darwin":
cmd = "open"
default:
cmd = "xdg-open"
}
args = append(args, url)
return exec.Command(cmd, args...).Start()
}

func (a *App) SetXRPCClient() error {

// Build xrpc.Client
Expand Down
16 changes: 8 additions & 8 deletions continent.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ func (a *App) DispatchCommand(text string) string {
case "/help":
{
if len(words) < 2 {
OpenURL("https://github.com/kakakaya/mazesoba-continent/blob/main/README.md")
runtime.BrowserOpenURL(a.ctx, "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")
runtime.BrowserOpenURL(a.ctx, "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")
runtime.BrowserOpenURL(a.ctx, "https://github.com/kakakaya/mazesoba-continent/tree/main/docs/SLASH_COMMAND.md")
}
default:
{
OpenURL("https://github.com/kakakaya/mazesoba-continent/blob/main/README.md")
runtime.BrowserOpenURL(a.ctx, "https://github.com/kakakaya/mazesoba-continent/blob/main/README.md")
}
}
return ""
Expand All @@ -54,7 +54,7 @@ func (a *App) DispatchCommand(text string) string {
case "profile":
{
handle_or_did := words[2]
OpenURL(fmt.Sprintf("https://bsky.app/profile/%s", handle_or_did))
runtime.BrowserOpenURL(a.ctx, fmt.Sprintf("https://bsky.app/profile/%s", handle_or_did))
}
case "search", "s":
{
Expand All @@ -71,11 +71,11 @@ func (a *App) DispatchCommand(text string) string {
q.Add("q", strings.Join(words[2:], " "))
req.URL.RawQuery = q.Encode()

OpenURL(req.URL.String())
runtime.BrowserOpenURL(a.ctx, req.URL.String())
}
default:
{
OpenURL(words[1]) // NOTE: TBC
runtime.BrowserOpenURL(a.ctx, words[1]) // NOTE: TBC
}
}
return ""
Expand Down Expand Up @@ -112,7 +112,7 @@ func (a *App) DispatchCommand(text string) string {
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")
runtime.BrowserOpenURL(a.ctx, "https://bsky.app/search?q=%E3%81%BE%E3%81%9C%E3%81%9D%E3%81%B0%E5%A4%A7%E9%99%B8")
}
}
return ""
Expand Down

0 comments on commit 9b7a6bc

Please sign in to comment.