mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add whois command
This commit is contained in:
parent
242b5cad81
commit
df16e5c3b1
2 changed files with 17 additions and 4 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -50,7 +51,22 @@ func Whois(username string) string {
|
|||
var responseObject whoisApiResponse
|
||||
json.Unmarshal(body, &responseObject)
|
||||
|
||||
reply := fmt.Sprintf("User: %s, ID: %s, Color: %s, Partner: %v, Affiliate: %v, Staff: %v, Admin: %v, Bot: %v, Bio: %v", responseObject.DisplayName, responseObject.Id, responseObject.ChatColor, responseObject.Roles.IsPartner, responseObject.Roles.IsAffiliate, responseObject.Roles.IsStaff, responseObject.Roles.IsSiteAdmin, responseObject.Bot, responseObject.Bio)
|
||||
// time string format 2011-05-19T00:28:28.310449Z
|
||||
// discard everything after T
|
||||
created := strings.Split(responseObject.CreatedAt, "T")
|
||||
|
||||
reply := fmt.Sprintf("User: %s, ID: %s, Created on: %s, Color: %s, Affiliate: %v, Partner: %v, Staff: %v, Admin: %v, Bot: %v, Bio: %v",
|
||||
responseObject.DisplayName,
|
||||
responseObject.Id,
|
||||
created[0],
|
||||
responseObject.ChatColor,
|
||||
responseObject.Roles.IsAffiliate,
|
||||
responseObject.Roles.IsPartner,
|
||||
responseObject.Roles.IsStaff,
|
||||
responseObject.Roles.IsSiteAdmin,
|
||||
responseObject.Bot,
|
||||
responseObject.Bio,
|
||||
)
|
||||
|
||||
// User not found
|
||||
if responseObject.Error != "" {
|
||||
|
|
|
@ -433,9 +433,6 @@ func Command(message twitch.PrivateMessage, nb *bot.Bot) {
|
|||
if msgLen == 1 {
|
||||
nb.Send(target, "Usage: ()whois [user]")
|
||||
return
|
||||
} else if message.User.ID != "31437432" {
|
||||
nb.Send(target, "You are not authorized to do that.")
|
||||
return
|
||||
} else {
|
||||
commands.Whois(target, cmdParams[1], nb)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue