v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-16 07:40:44 -07:00

style: userAgent to const string

This commit is contained in:
eeeXun 2023-03-06 00:42:35 +08:00
parent fcf2e0020a
commit 05c963f2d1
4 changed files with 6 additions and 5 deletions

View File

@ -90,7 +90,7 @@ Stop play sound.
Toggle transparent.
`<C-\>`
Toggle Definition/Example & Part of speech
Toggle Definition/Example & Part of speech.
`<Tab>`, `<S-Tab>`
Cycle through the pop out widget.

View File

@ -13,7 +13,8 @@ import (
)
const (
textURL = "https://api.reverso.net/translate/v1/translation"
textURL = "https://api.reverso.net/translate/v1/translation"
userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
)
type ReversoTranslate struct {
@ -70,7 +71,7 @@ func (t *ReversoTranslate) Translate(message string) (translation, definition, p
textURL,
bytes.NewBuffer([]byte(userData)))
req.Header.Add("Content-Type", "application/json")
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36")
req.Header.Add("User-Agent", userAgent)
res, err := http.DefaultClient.Do(req)
if err != nil {
return "", "", "", err

View File

@ -38,7 +38,7 @@ func (t *ReversoTranslate) PlayTTS(lang, message string) error {
base64.StdEncoding.EncodeToString([]byte(message)),
)
req, _ := http.NewRequest("GET", urlStr, nil)
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36")
req.Header.Add("User-Agent", userAgent)
res, err := http.DefaultClient.Do(req)
if err != nil {
t.SoundLock.Release()

2
ui.go
View File

@ -38,7 +38,7 @@ const (
[#%[1]s]<C-t>[-]
Toggle transparent.
[#%[1]s]<C-\>[-]
Toggle Definition/Example & Part of speech
Toggle Definition/Example & Part of speech.
[#%[1]s]<Tab>, <S-Tab>[-]
Cycle through the pop out widget.
[#%[1]s]<1>, <2>, <3>[-]