mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-08 08:10:08 +00:00
[core] Fix: Clean usernames when querying user information
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
8c93544573
commit
8a40f105e3
1 changed files with 7 additions and 0 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -45,6 +46,8 @@ func (c *Client) GetAuthorizedUser() (userID string, userName string, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetDisplayNameForUser(username string) (string, error) {
|
func (c *Client) GetDisplayNameForUser(username string) (string, error) {
|
||||||
|
username = strings.TrimLeft(username, "#@")
|
||||||
|
|
||||||
cacheKey := []string{"displayNameForUsername", username}
|
cacheKey := []string{"displayNameForUsername", username}
|
||||||
if d := c.apiCache.Get(cacheKey); d != nil {
|
if d := c.apiCache.Get(cacheKey); d != nil {
|
||||||
return d.(string), nil
|
return d.(string), nil
|
||||||
|
@ -124,6 +127,8 @@ func (c *Client) GetFollowDate(from, to string) (time.Time, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetIDForUsername(username string) (string, error) {
|
func (c *Client) GetIDForUsername(username string) (string, error) {
|
||||||
|
username = strings.TrimLeft(username, "#@")
|
||||||
|
|
||||||
cacheKey := []string{"idForUsername", username}
|
cacheKey := []string{"idForUsername", username}
|
||||||
if d := c.apiCache.Get(cacheKey); d != nil {
|
if d := c.apiCache.Get(cacheKey); d != nil {
|
||||||
return d.(string), nil
|
return d.(string), nil
|
||||||
|
@ -155,6 +160,8 @@ func (c *Client) GetIDForUsername(username string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetUserInformation(user string) (*User, error) {
|
func (c *Client) GetUserInformation(user string) (*User, error) {
|
||||||
|
user = strings.TrimLeft(user, "#@")
|
||||||
|
|
||||||
var (
|
var (
|
||||||
out User
|
out User
|
||||||
param = "login"
|
param = "login"
|
||||||
|
|
Loading…
Reference in a new issue