-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a89444b
commit 7b3b210
Showing
13 changed files
with
252 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,92 @@ | ||
package telebot | ||
|
||
import "encoding/json" | ||
|
||
func (b *Bot) SetMyDescription(description, languageCode string) error { | ||
_, err := b.Raw("setMyCommands", map[string]interface{}{ | ||
"description": description, | ||
"language_code": languageCode, | ||
}) | ||
return err | ||
} | ||
|
||
type BotDescription struct { | ||
Description string `json:"description"` | ||
} | ||
|
||
func (b *Bot) GetMyDescription(languageCode string) (*BotDescription, error) { | ||
params := map[string]string{ | ||
"language_code": languageCode, | ||
} | ||
|
||
data, err := b.Raw("getMyCommands", params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var resp struct { | ||
Result BotDescription | ||
} | ||
if err := json.Unmarshal(data, &resp); err != nil { | ||
return nil, wrapError(err) | ||
} | ||
return &resp.Result, nil | ||
} | ||
|
||
func (b *Bot) SetMyShortDescription(shortDescription, languageCode string) error { | ||
_, err := b.Raw("setMyShortDescription", map[string]interface{}{ | ||
"short_description": shortDescription, | ||
"language_code": languageCode, | ||
}) | ||
return err | ||
} | ||
|
||
type BotShortDescription struct { | ||
ShortDescription string `json:"short_description"` | ||
} | ||
|
||
func (b *Bot) GetMyShortDescription(languageCode string) (*BotShortDescription, error) { | ||
data, err := b.Raw("getMyCommands", map[string]string{ | ||
"language_code": languageCode, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var resp struct { | ||
Result BotShortDescription | ||
} | ||
if err := json.Unmarshal(data, &resp); err != nil { | ||
return nil, wrapError(err) | ||
} | ||
return &resp.Result, nil | ||
} | ||
|
||
func (b *Bot) SetMyName(name, languageCode string) error { | ||
_, err := b.Raw("setMyName", map[string]interface{}{ | ||
"name": name, | ||
"language_code": languageCode, | ||
}) | ||
return err | ||
} | ||
|
||
type BotName struct { | ||
Name string `json:"name"` | ||
} | ||
|
||
func (b *Bot) GetMyName(languageCode string) (*BotName, error) { | ||
data, err := b.Raw("getMyCommands", map[string]string{ | ||
"language_code": languageCode, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var resp struct { | ||
Result BotName | ||
} | ||
if err := json.Unmarshal(data, &resp); err != nil { | ||
return nil, wrapError(err) | ||
} | ||
return &resp.Result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.