commit
58fd3a752c
28
bot.go
28
bot.go
@ -6,6 +6,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -384,7 +386,31 @@ func GetQrcodeUrl(uuid string) string {
|
|||||||
// PrintlnQrcodeUrl 打印登录二维码
|
// PrintlnQrcodeUrl 打印登录二维码
|
||||||
func PrintlnQrcodeUrl(uuid string) {
|
func PrintlnQrcodeUrl(uuid string) {
|
||||||
println("访问下面网址扫描二维码登录")
|
println("访问下面网址扫描二维码登录")
|
||||||
println(GetQrcodeUrl(uuid))
|
qrcodeUrl := GetQrcodeUrl(uuid)
|
||||||
|
println(qrcodeUrl)
|
||||||
|
|
||||||
|
// browser open the login url
|
||||||
|
_ = open(qrcodeUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// open opens the specified URL in the default browser of the user.
|
||||||
|
func open(url string) error {
|
||||||
|
var (
|
||||||
|
cmd string
|
||||||
|
args []string
|
||||||
|
)
|
||||||
|
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "windows":
|
||||||
|
cmd, args = "cmd", []string{"/c", "start"}
|
||||||
|
case "darwin":
|
||||||
|
cmd = "open"
|
||||||
|
default:
|
||||||
|
// "linux", "freebsd", "openbsd", "netbsd"
|
||||||
|
cmd = "xdg-open"
|
||||||
|
}
|
||||||
|
args = append(args, url)
|
||||||
|
return exec.Command(cmd, args...).Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bot) handleMessage(messageList []*Message) {
|
func (b *Bot) handleMessage(messageList []*Message) {
|
||||||
|
@ -33,7 +33,7 @@ func (f *Friend) SendImage(file *os.File) (*SentMessage, error) {
|
|||||||
return f.Self.SendImageToFriend(f, file)
|
return f.Self.SendImageToFriend(f, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendVideo 发送图片消息
|
// SendVideo 发送视频消息
|
||||||
func (f *Friend) SendVideo(file *os.File) (*SentMessage, error) {
|
func (f *Friend) SendVideo(file *os.File) (*SentMessage, error) {
|
||||||
return f.Self.SendVideoToFriend(f, file)
|
return f.Self.SendVideoToFriend(f, file)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user