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"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -50,7 +51,22 @@ func Whois(username string) string {
|
||||||
var responseObject whoisApiResponse
|
var responseObject whoisApiResponse
|
||||||
json.Unmarshal(body, &responseObject)
|
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
|
// User not found
|
||||||
if responseObject.Error != "" {
|
if responseObject.Error != "" {
|
||||||
|
|
|
@ -433,9 +433,6 @@ func Command(message twitch.PrivateMessage, nb *bot.Bot) {
|
||||||
if msgLen == 1 {
|
if msgLen == 1 {
|
||||||
nb.Send(target, "Usage: ()whois [user]")
|
nb.Send(target, "Usage: ()whois [user]")
|
||||||
return
|
return
|
||||||
} else if message.User.ID != "31437432" {
|
|
||||||
nb.Send(target, "You are not authorized to do that.")
|
|
||||||
return
|
|
||||||
} else {
|
} else {
|
||||||
commands.Whois(target, cmdParams[1], nb)
|
commands.Whois(target, cmdParams[1], nb)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue