mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 20:01:17 +00:00
Expose GetIDForUsername function
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
44673eadd2
commit
9451354d30
1 changed files with 4 additions and 4 deletions
|
@ -105,11 +105,11 @@ func (c Client) GetFollowDate(from, to string) (time.Time, error) {
|
||||||
return d.(time.Time), nil
|
return d.(time.Time), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
fromID, err := c.getIDForUsername(from)
|
fromID, err := c.GetIDForUsername(from)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return time.Time{}, errors.Wrap(err, "getting id for 'from' user")
|
return time.Time{}, errors.Wrap(err, "getting id for 'from' user")
|
||||||
}
|
}
|
||||||
toID, err := c.getIDForUsername(to)
|
toID, err := c.GetIDForUsername(to)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return time.Time{}, errors.Wrap(err, "getting id for 'to' user")
|
return time.Time{}, errors.Wrap(err, "getting id for 'to' user")
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ func (c Client) HasLiveStream(username string) (bool, error) {
|
||||||
return len(payload.Data) == 1 && payload.Data[0].Type == "live", nil
|
return len(payload.Data) == 1 && payload.Data[0].Type == "live", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) getIDForUsername(username string) (string, error) {
|
func (c Client) GetIDForUsername(username string) (string, error) {
|
||||||
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
|
||||||
|
@ -209,7 +209,7 @@ func (c Client) GetRecentStreamInfo(username string) (string, string, error) {
|
||||||
return d.([2]string)[0], d.([2]string)[1], nil
|
return d.([2]string)[0], d.([2]string)[1], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := c.getIDForUsername(username)
|
id, err := c.GetIDForUsername(username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", errors.Wrap(err, "getting ID for username")
|
return "", "", errors.Wrap(err, "getting ID for username")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue