mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
styling and cleanup
This commit is contained in:
parent
4bfc29c1b6
commit
6911603401
|
@ -49,11 +49,13 @@ func (app *application) AddCommand(name string, message twitch.PrivateMessage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCommand queries the database for a command with the provided name. If an entry exists
|
// GetCommand queries the database for a command with the provided name.
|
||||||
// it checks if the Command.Level is 0, if it is the command.Text value is returned.
|
// If an entry exists it checks if the Command.Level is 0, if it is
|
||||||
|
// the command.Text value is returned.
|
||||||
//
|
//
|
||||||
// If the Command.Level is not 0 it queries the database for the level of the user who sent
|
// If the Command.Level is not 0 it queries the database for the level of the
|
||||||
// the message. If the users level is equal or higher the command.Text field is returned.
|
// user who sent the message. If the users level is equal or higher
|
||||||
|
// the command.Text field is returned.
|
||||||
func (app *application) GetCommand(target, commandName string, userLevel int) (string, error) {
|
func (app *application) GetCommand(target, commandName string, userLevel int) (string, error) {
|
||||||
app.Log.Infow("command",
|
app.Log.Infow("command",
|
||||||
"target", target,
|
"target", target,
|
||||||
|
@ -78,11 +80,14 @@ func (app *application) GetCommand(target, commandName string, userLevel int) (s
|
||||||
return "", ErrUserInsufficientLevel
|
return "", ErrUserInsufficientLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCommandDescription queries the database for a command with the provided name in the channel.
|
// GetCommandDescription queries the database for a command with the provided
|
||||||
// If a command exist it then checks if the Command.Level is 0, if it is the command.Text value is returned.
|
// name in the channel.
|
||||||
|
// If a command exist it then checks if the Command.Level is 0, if it is
|
||||||
|
// the command.Text value is returned.
|
||||||
//
|
//
|
||||||
// If the Command.Level is not 0 it queries the database for the level of the user who sent
|
// If the Command.Level is not 0 it queries the database for the level of
|
||||||
// the message. If the users level is equal or higher the command.Text field is returned.
|
// the user that sent the message. If the users level is equal or higher
|
||||||
|
// the command.Text field is returned.
|
||||||
func (app *application) GetCommandDescription(name, channel, username string) (string, error) {
|
func (app *application) GetCommandDescription(name, channel, username string) (string, error) {
|
||||||
command, err := app.Models.Commands.Get(name, channel)
|
command, err := app.Models.Commands.Get(name, channel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -110,25 +115,31 @@ func (app *application) GetCommandDescription(name, channel, username string) (s
|
||||||
return "", ErrUserInsufficientLevel
|
return "", ErrUserInsufficientLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditCommandLevel checks if a command with the provided name exists in the database. If it does it
|
// EditCommandLevel checks if a command with the provided name exists in
|
||||||
// changes the level of the command with the supplied value.
|
// the database. If it exists it changes the level of the command in
|
||||||
|
// the database with the newly supplied level value.
|
||||||
func (app *application) EditCommandLevel(name, lvl string, message twitch.PrivateMessage) {
|
func (app *application) EditCommandLevel(name, lvl string, message twitch.PrivateMessage) {
|
||||||
level, err := strconv.Atoi(lvl)
|
level, err := strconv.Atoi(lvl)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrCommandLevelNotInteger), message)
|
app.Send(message.Channel,
|
||||||
|
fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrCommandLevelNotInteger), message)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.Models.Commands.SetLevel(name, message.Channel, level)
|
err = app.Models.Commands.SetLevel(name, message.Channel, level)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
app.Send(message.Channel,
|
||||||
|
fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
|
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
reply := fmt.Sprintf("Updated command %s to level %v", name, level)
|
reply := fmt.Sprintf("Updated command %s to level %v", name, level)
|
||||||
app.Send(message.Channel, reply, message)
|
app.Send(message.Channel, reply, message)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,11 +290,10 @@ func (app *application) ListChannelCommands(channel string) string {
|
||||||
|
|
||||||
// The slice of timers is only used to log them at
|
// The slice of timers is only used to log them at
|
||||||
// the start so it looks a bit nicer.
|
// the start so it looks a bit nicer.
|
||||||
var cs []string
|
|
||||||
|
|
||||||
allHelpText := app.GetAllHelpText()
|
allHelpText := app.GetAllHelpText()
|
||||||
|
var cs = []string{fmt.Sprintf("General commands: \n\n%s\nChannel commands:\n\n", allHelpText)}
|
||||||
app.Log.Info(allHelpText)
|
app.Log.Info(allHelpText)
|
||||||
cs = append(cs, fmt.Sprintf("General commands: \n\n%s\nChannel commands:\n\n", allHelpText))
|
|
||||||
|
|
||||||
// Iterate over all timers and then add them onto the scheduler.
|
// Iterate over all timers and then add them onto the scheduler.
|
||||||
for i, v := range command {
|
for i, v := range command {
|
||||||
|
@ -291,9 +301,8 @@ func (app *application) ListChannelCommands(channel string) string {
|
||||||
// https://github.com/robfig/cron/issues/420#issuecomment-940949195
|
// https://github.com/robfig/cron/issues/420#issuecomment-940949195
|
||||||
i, v := i, v
|
i, v := i, v
|
||||||
_ = i
|
_ = i
|
||||||
var c string
|
|
||||||
|
|
||||||
c = fmt.Sprintf(
|
c := fmt.Sprintf(
|
||||||
"Name: \t%v\n"+
|
"Name: \t%v\n"+
|
||||||
"Description: %v\n"+
|
"Description: %v\n"+
|
||||||
"Level: \t%v\n"+
|
"Level: \t%v\n"+
|
||||||
|
|
|
@ -12,8 +12,9 @@ import (
|
||||||
"github.com/lyx0/nourybot/pkg/owm"
|
"github.com/lyx0/nourybot/pkg/owm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// handleCommand takes in a twitch.PrivateMessage and then routes the message to
|
// handleCommand takes in a twitch.PrivateMessage and then routes the message
|
||||||
// the function that is responsible for each command and knows how to deal with it accordingly.
|
// to the function that is responsible for each command and knows how to deal
|
||||||
|
// with it accordingly.
|
||||||
func (app *application) handleCommand(message twitch.PrivateMessage) {
|
func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
var reply string
|
var reply string
|
||||||
|
|
||||||
|
@ -21,7 +22,8 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increments the counter how many commands have been used, called in the ping command.
|
// Increments the counter how many commands have been used,
|
||||||
|
// called in the ping command.
|
||||||
go common.CommandUsed()
|
go common.CommandUsed()
|
||||||
|
|
||||||
go app.InitUser(message.User.Name, message.User.ID)
|
go app.InitUser(message.User.Name, message.User.ID)
|
||||||
|
@ -134,6 +136,9 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
case "youtube":
|
case "youtube":
|
||||||
reply = commands.Youtube(message.Message[10:len(message.Message)])
|
reply = commands.Youtube(message.Message[10:len(message.Message)])
|
||||||
|
|
||||||
|
case "godoc":
|
||||||
|
reply = commands.Godocs(message.Message[8:len(message.Message)])
|
||||||
|
|
||||||
case "godocs":
|
case "godocs":
|
||||||
reply = commands.Godocs(message.Message[9:len(message.Message)])
|
reply = commands.Godocs(message.Message[9:len(message.Message)])
|
||||||
|
|
||||||
|
@ -202,10 +207,10 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
reply, _ = app.getUserID(cmdParams[1])
|
reply, _ = app.getUserID(cmdParams[1])
|
||||||
|
|
||||||
case "uname":
|
case "uname":
|
||||||
reply, _ = app.getChannelUsername(cmdParams[1])
|
reply, _ = app.userIDtoUsername(cmdParams[1])
|
||||||
|
|
||||||
case "username":
|
case "username":
|
||||||
reply, _ = app.getChannelUsername(cmdParams[1])
|
reply, _ = app.userIDtoUsername(cmdParams[1])
|
||||||
|
|
||||||
case "commands":
|
case "commands":
|
||||||
reply = app.ListChannelCommands(message.Channel)
|
reply = app.ListChannelCommands(message.Channel)
|
||||||
|
@ -549,10 +554,10 @@ var helpText = map[string]command{
|
||||||
},
|
},
|
||||||
"godocs": {
|
"godocs": {
|
||||||
Name: "godocs",
|
Name: "godocs",
|
||||||
Alias: nil,
|
Alias: []string{"godocs", "godoc"},
|
||||||
Description: "Returns the godocs.io search URL for a given query.",
|
Description: "Returns the godocs.io search URL for a given query.",
|
||||||
Level: "0",
|
Level: "0",
|
||||||
Usage: "()godoc <query>",
|
Usage: "()godocs <query>",
|
||||||
},
|
},
|
||||||
"gofile": {
|
"gofile": {
|
||||||
Name: "gofile",
|
Name: "gofile",
|
||||||
|
@ -753,7 +758,7 @@ var helpText = map[string]command{
|
||||||
"weather": {
|
"weather": {
|
||||||
Name: "weather",
|
Name: "weather",
|
||||||
Alias: nil,
|
Alias: nil,
|
||||||
Description: `Returns the weather for a given location. If you "$set location" your location, the command will use that location if no other location is specified.`,
|
Description: `Returns the weather for a given location. If you "()set location" your location, the command will use that location if no other location is specified.`,
|
||||||
Level: "0",
|
Level: "0",
|
||||||
Usage: "()weather [location]",
|
Usage: "()weather [location]",
|
||||||
},
|
},
|
||||||
|
@ -810,9 +815,19 @@ func (app *application) GetAllHelpText() string {
|
||||||
var c string
|
var c string
|
||||||
|
|
||||||
if v.Alias == nil {
|
if v.Alias == nil {
|
||||||
c = fmt.Sprintf("Name: %s\nDescription: %s\nLevel: %s\nUsage: %s\n\n", i, v.Description, v.Level, v.Usage)
|
c = fmt.Sprintf("Name: %s\nDescription: %s\nLevel: %s\nUsage: %s\n\n",
|
||||||
|
i,
|
||||||
|
v.Description,
|
||||||
|
v.Level,
|
||||||
|
v.Usage,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
c = fmt.Sprintf("Name: %s\nAliases: %s\nDescription: %s\nLevel: %s\nUsage: %s\n\n", i, v.Alias, v.Description, v.Level, v.Usage)
|
c = fmt.Sprintf("Name: %s\nAliases: %s\nDescription: %s\nLevel: %s\nUsage: %s\n\n",
|
||||||
|
i, v.Alias,
|
||||||
|
v.Description,
|
||||||
|
v.Level,
|
||||||
|
v.Usage,
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ func (app *application) ConvertAndSave(fName, link string, msg twitch.PrivateMes
|
||||||
fn, err := os.Create(out)
|
fn, err := os.Create(out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(msg.Channel, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
app.Send(msg.Channel, fmt.Sprint(ErrGenericErrorMessage), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer fn.Close()
|
defer fn.Close()
|
||||||
|
@ -95,6 +95,11 @@ func (app *application) ConvertAndSave(fName, link string, msg twitch.PrivateMes
|
||||||
err = ffmpeg.Input(fileName).
|
err = ffmpeg.Input(fileName).
|
||||||
Output(out).
|
Output(out).
|
||||||
OverWriteOutput().ErrorToStdOut().Run()
|
OverWriteOutput().ErrorToStdOut().Run()
|
||||||
|
if err != nil {
|
||||||
|
app.Log.Errorln(err)
|
||||||
|
app.Send(msg.Channel, fmt.Sprint(ErrGenericErrorMessage), msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
defer os.Remove(fileName)
|
defer os.Remove(fileName)
|
||||||
app.Send(msg.Channel, fmt.Sprintf("https://bot.noury.li/uploads/%s.mp4", fName), msg)
|
app.Send(msg.Channel, fmt.Sprintf("https://bot.noury.li/uploads/%s.mp4", fName), msg)
|
||||||
|
@ -160,6 +165,11 @@ func (app *application) ConvertToMP4(link string, msg twitch.PrivateMessage) {
|
||||||
err = ffmpeg.Input(fileName).
|
err = ffmpeg.Input(fileName).
|
||||||
Output(out).
|
Output(out).
|
||||||
OverWriteOutput().ErrorToStdOut().Run()
|
OverWriteOutput().ErrorToStdOut().Run()
|
||||||
|
if err != nil {
|
||||||
|
app.Log.Errorln(err)
|
||||||
|
app.Send(msg.Channel, fmt.Sprint(ErrGenericErrorMessage), msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
defer os.Remove(fileName)
|
defer os.Remove(fileName)
|
||||||
go app.NewUpload("yaf", out, msg.Channel, uuid_new, msg)
|
go app.NewUpload("yaf", out, msg.Channel, uuid_new, msg)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
ErrGenericErrorMessage = errors.New("something went wrong FeelsBadMan")
|
||||||
ErrUserLevelNotInteger = errors.New("user level must be a number")
|
ErrUserLevelNotInteger = errors.New("user level must be a number")
|
||||||
ErrCommandLevelNotInteger = errors.New("command level must be a number")
|
ErrCommandLevelNotInteger = errors.New("command level must be a number")
|
||||||
ErrRecordNotFound = errors.New("user not found in the database")
|
ErrRecordNotFound = errors.New("user not found in the database")
|
||||||
|
|
|
@ -103,7 +103,8 @@ func (app *application) deleteLiveSubscription(target, channel string) string {
|
||||||
return fmt.Sprintf("Successfully deleted live notification for channel %s; id=%v", channel, uid)
|
return fmt.Sprintf("Successfully deleted live notification for channel %s; id=%v", channel, uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// createOfflineSubscription creates a stream.offline twitch eventsub subscription for the specified channel
|
// createOfflineSubscription creates a stream.offline twitch eventsub
|
||||||
|
// subscription for the specified channel.
|
||||||
func (app *application) createOfflineSubscription(target, channel string) string {
|
func (app *application) createOfflineSubscription(target, channel string) string {
|
||||||
uid := ivr.IDByUsername(channel)
|
uid := ivr.IDByUsername(channel)
|
||||||
if uid == "xd" {
|
if uid == "xd" {
|
||||||
|
@ -133,7 +134,8 @@ func (app *application) createOfflineSubscription(target, channel string) string
|
||||||
return fmt.Sprintf("Created offline subscription for channel %v; uid=%v", channel, uid)
|
return fmt.Sprintf("Created offline subscription for channel %v; uid=%v", channel, uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleteOfflineSubscription deletes a stream.offline twitch eventsub subscription for the specified channel
|
// deleteOfflineSubscription deletes a stream.offline twitch eventsub
|
||||||
|
// subscription for the specified channel
|
||||||
func (app *application) deleteOfflineSubscription(target, channel string) string {
|
func (app *application) deleteOfflineSubscription(target, channel string) string {
|
||||||
uid := ivr.IDByUsername(channel)
|
uid := ivr.IDByUsername(channel)
|
||||||
if uid == "xd" {
|
if uid == "xd" {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"github.com/nicklaw5/helix/v2"
|
"github.com/nicklaw5/helix/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// getUserID returns the Twitch userID for given twitch username.
|
||||||
func (app *application) getUserID(username string) (string, error) {
|
func (app *application) getUserID(username string) (string, error) {
|
||||||
resp, err := app.HelixClient.GetUsers(&helix.UsersParams{
|
resp, err := app.HelixClient.GetUsers(&helix.UsersParams{
|
||||||
Logins: []string{username},
|
Logins: []string{username},
|
||||||
|
@ -16,7 +17,8 @@ func (app *application) getUserID(username string) (string, error) {
|
||||||
return resp.Data.Users[0].ID, nil
|
return resp.Data.Users[0].ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) getChannelUsername(channelID string) (string, error) {
|
// userIDtoUsername returns the Twitch username for a given twitch user ID.
|
||||||
|
func (app *application) userIDtoUsername(channelID string) (string, error) {
|
||||||
resp, err := app.HelixClient.GetUsers(&helix.UsersParams{
|
resp, err := app.HelixClient.GetUsers(&helix.UsersParams{
|
||||||
IDs: []string{channelID},
|
IDs: []string{channelID},
|
||||||
})
|
})
|
||||||
|
@ -28,6 +30,8 @@ func (app *application) getChannelUsername(channelID string) (string, error) {
|
||||||
return resp.Data.Users[0].Login, nil
|
return resp.Data.Users[0].Login, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getChannelTitle queries the Twitch API for the current Title for
|
||||||
|
// the provided Twitch channel username.
|
||||||
func (app *application) getChannelTitle(channelID string) string {
|
func (app *application) getChannelTitle(channelID string) string {
|
||||||
resp, err := app.HelixClient.GetChannelInformation(&helix.GetChannelInformationParams{
|
resp, err := app.HelixClient.GetChannelInformation(&helix.GetChannelInformationParams{
|
||||||
BroadcasterID: channelID,
|
BroadcasterID: channelID,
|
||||||
|
@ -40,6 +44,8 @@ func (app *application) getChannelTitle(channelID string) string {
|
||||||
return resp.Data.Channels[0].Title
|
return resp.Data.Channels[0].Title
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getChannelTitleByUsername returns the current title of the provided
|
||||||
|
// Twitch channel username.
|
||||||
func (app *application) getChannelTitleByUsername(username string) string {
|
func (app *application) getChannelTitleByUsername(username string) string {
|
||||||
channelID, err := app.getUserID(username)
|
channelID, err := app.getUserID(username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -178,11 +178,15 @@ func run(ctx context.Context, w io.Writer, args []string) error {
|
||||||
|
|
||||||
app.TwitchClient.OnClearChatMessage(func(message twitch.ClearChatMessage) {
|
app.TwitchClient.OnClearChatMessage(func(message twitch.ClearChatMessage) {
|
||||||
if message.BanDuration == 0 && message.Channel == "forsen" {
|
if message.BanDuration == 0 && message.Channel == "forsen" {
|
||||||
app.TwitchClient.Say("nouryxd", fmt.Sprintf("MODS https://logs.ivr.fi/?channel=forsen&username=%v", message.TargetUsername))
|
app.TwitchClient.Say("nouryxd",
|
||||||
|
fmt.Sprintf("MODS https://logs.ivr.fi/?channel=forsen&username=%v",
|
||||||
|
message.TargetUsername))
|
||||||
}
|
}
|
||||||
|
|
||||||
if message.BanDuration >= 28700 && message.Channel == "forsen" {
|
if message.BanDuration >= 28700 && message.Channel == "forsen" {
|
||||||
app.TwitchClient.Say("nouryxd", fmt.Sprintf("monkaS -%v https://logs.ivr.fi/?channel=forsen&username=%v", message.BanDuration, message.TargetUsername))
|
app.TwitchClient.Say("nouryxd",
|
||||||
|
fmt.Sprintf("monkaS -%v https://logs.ivr.fi/?channel=forsen&username=%v",
|
||||||
|
message.BanDuration, message.TargetUsername))
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -27,7 +27,7 @@ func (app *application) startRouter() {
|
||||||
router.GET("/timer", app.timersRoute)
|
router.GET("/timer", app.timersRoute)
|
||||||
router.GET("/timer/:channel", app.channelTimersRoute)
|
router.GET("/timer/:channel", app.channelTimersRoute)
|
||||||
|
|
||||||
// Serve files uploaded by the meme command, but don't list the directory contents.
|
// Serve files uploaded by the meme command, but don't list directory contents.
|
||||||
fs := justFilesFilesystem{http.Dir("/public/uploads/")}
|
fs := justFilesFilesystem{http.Dir("/public/uploads/")}
|
||||||
router.Handler("GET", "/uploads/*filepath", http.StripPrefix("/uploads", http.FileServer(fs)))
|
router.Handler("GET", "/uploads/*filepath", http.StripPrefix("/uploads", http.FileServer(fs)))
|
||||||
|
|
||||||
|
@ -41,10 +41,11 @@ type eventSubNotification struct {
|
||||||
Event json.RawMessage `json:"event"`
|
Event json.RawMessage `json:"event"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// eventsubMessageId stores the last message id of an event sub. Twitch resends events
|
// eventsubSubscriptionID stores the received eventsub subscription ids since
|
||||||
// if it is unsure that you have gotten them so we check if the last event has the same
|
// last restart. Twitch resends events if it is unsure that we have gotten them
|
||||||
// message id and if it does discard the event.
|
// so we check if the received eventsub subscription id has already
|
||||||
var lastEventSubSubscriptionId = []string{"xd"}
|
// been recorded and discard them if so.
|
||||||
|
var lastEventSubSubscriptionID = []string{"xd"}
|
||||||
|
|
||||||
func (app *application) eventsubFollow(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
func (app *application) eventsubFollow(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
channel := ps.ByName("channel")
|
channel := ps.ByName("channel")
|
||||||
|
@ -68,7 +69,8 @@ func (app *application) eventsubFollow(w http.ResponseWriter, r *http.Request, p
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// if there's a challenge in the request, respond with only the challenge to verify your eventsub.
|
// if there's a challenge in the request, respond
|
||||||
|
// with only the challenge to verify the request is genuine.
|
||||||
if vals.Challenge != "" {
|
if vals.Challenge != "" {
|
||||||
w.Write([]byte(vals.Challenge))
|
w.Write([]byte(vals.Challenge))
|
||||||
return
|
return
|
||||||
|
@ -77,11 +79,11 @@ func (app *application) eventsubFollow(w http.ResponseWriter, r *http.Request, p
|
||||||
|
|
||||||
// Check if the current events subscription id equals the last events.
|
// Check if the current events subscription id equals the last events.
|
||||||
// If it does ignore the event since it's a repeated event.
|
// If it does ignore the event since it's a repeated event.
|
||||||
for i := 0; i < len(lastEventSubSubscriptionId); i++ {
|
for i := 0; i < len(lastEventSubSubscriptionID); i++ {
|
||||||
if vals.Subscription.ID == lastEventSubSubscriptionId[i] {
|
if vals.Subscription.ID == lastEventSubSubscriptionID[i] {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
lastEventSubSubscriptionId[i] = vals.Subscription.ID
|
lastEventSubSubscriptionID[i] = vals.Subscription.ID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,22 +92,39 @@ func (app *application) eventsubFollow(w http.ResponseWriter, r *http.Request, p
|
||||||
var liveEvent helix.EventSubStreamOnlineEvent
|
var liveEvent helix.EventSubStreamOnlineEvent
|
||||||
|
|
||||||
err = json.NewDecoder(bytes.NewReader(vals.Event)).Decode(&liveEvent)
|
err = json.NewDecoder(bytes.NewReader(vals.Event)).Decode(&liveEvent)
|
||||||
log.Printf("got stream online event webhook: [%s]: %s is live\n", channel, liveEvent.BroadcasterUserName)
|
if err != nil {
|
||||||
|
app.Log.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("got stream online event webhook: [%s]: %s is live\n",
|
||||||
|
channel, liveEvent.BroadcasterUserName)
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
w.Write([]byte("ok"))
|
w.Write([]byte("ok"))
|
||||||
|
|
||||||
game := app.getChannelGame(liveEvent.BroadcasterUserID)
|
game := app.getChannelGame(liveEvent.BroadcasterUserID)
|
||||||
title := app.getChannelTitle(liveEvent.BroadcasterUserID)
|
title := app.getChannelTitle(liveEvent.BroadcasterUserID)
|
||||||
|
|
||||||
app.SendNoBanphrase(channel, fmt.Sprintf("%s went live FeelsGoodMan Game: %s; Title: %s; https://twitch.tv/%s", liveEvent.BroadcasterUserName, game, title, liveEvent.BroadcasterUserLogin))
|
go app.SendNoBanphrase(channel,
|
||||||
|
fmt.Sprintf("@%s went live FeelsGoodMan Game: %s; Title: %s; https://twitch.tv/%s",
|
||||||
|
liveEvent.BroadcasterUserName, game, title, liveEvent.BroadcasterUserLogin))
|
||||||
|
|
||||||
case helix.EventSubTypeStreamOffline:
|
case helix.EventSubTypeStreamOffline:
|
||||||
var offlineEvent helix.EventSubStreamOfflineEvent
|
var offlineEvent helix.EventSubStreamOfflineEvent
|
||||||
|
|
||||||
err = json.NewDecoder(bytes.NewReader(vals.Event)).Decode(&offlineEvent)
|
err = json.NewDecoder(bytes.NewReader(vals.Event)).Decode(&offlineEvent)
|
||||||
log.Printf("got stream online event webhook: [%s]: %s is live\n", channel, offlineEvent.BroadcasterUserName)
|
if err != nil {
|
||||||
|
app.Log.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("got stream offline event webhook: [%s]: %s is offline\n",
|
||||||
|
channel, offlineEvent.BroadcasterUserName)
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
w.Write([]byte("ok"))
|
w.Write([]byte("ok"))
|
||||||
app.SendNoBanphrase(channel, fmt.Sprintf("%s went offline FeelsBadMan", offlineEvent.BroadcasterUserName))
|
|
||||||
|
go app.SendNoBanphrase(channel,
|
||||||
|
fmt.Sprintf("%s went offline FeelsBadMan", offlineEvent.BroadcasterUserName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,9 +248,13 @@ func (app *application) commandsRoute(w http.ResponseWriter, r *http.Request, _
|
||||||
var c string
|
var c string
|
||||||
|
|
||||||
if v.Alias == nil {
|
if v.Alias == nil {
|
||||||
c = fmt.Sprintf("Name: %s\nDescription: %s\nLevel: %s\nUsage: %s\n\n", i, v.Description, v.Level, v.Usage)
|
c = fmt.Sprintf(
|
||||||
|
"Name: %s\nDescription: %s\nLevel: %s\nUsage: %s\n\n",
|
||||||
|
i, v.Description, v.Level, v.Usage)
|
||||||
} else {
|
} else {
|
||||||
c = fmt.Sprintf("Name: %s\nAliases: %s\nDescription: %s\nLevel: %s\nUsage: %s\n\n", i, v.Alias, v.Description, v.Level, v.Usage)
|
c = fmt.Sprintf(
|
||||||
|
"Name: %s\nAliases: %s\nDescription: %s\nLevel: %s\nUsage: %s\n\n",
|
||||||
|
i, v.Alias, v.Description, v.Level, v.Usage)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,12 +359,17 @@ func (app *application) statusPageRoute(w http.ResponseWriter, r *http.Request,
|
||||||
started := common.GetUptime().Format("2006-1-2 15:4:5")
|
started := common.GetUptime().Format("2006-1-2 15:4:5")
|
||||||
commitLink := fmt.Sprintf("https://github.com/lyx0/nourybot/commit/%v", common.GetVersionPure())
|
commitLink := fmt.Sprintf("https://github.com/lyx0/nourybot/commit/%v", common.GetVersionPure())
|
||||||
|
|
||||||
fmt.Fprintf(w, fmt.Sprintf("started: \t%v\nenvironment: \t%v\ncommit: \t%v\ngithub: \t%v", started, app.Environment, commit, commitLink))
|
fmt.Print(w, fmt.Sprint(
|
||||||
|
"started: \t"+started+"\n"+
|
||||||
|
"environment: \t"+app.Environment+"\n"+
|
||||||
|
"commit: \t"+commit+"\n"+
|
||||||
|
"github: \t"+commitLink,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since I want to serve the files that I uploaded with the meme command to the /public/uploads
|
// Since I want to serve the files that I upload with the meme command to
|
||||||
// folder, but not list the directory on the `/uploads/` route I found this issue that solves
|
// the /public/uploads folder but not list the directory contents of
|
||||||
// that problem with the httprouter.
|
// the `/uploads/` route I found this issue that solves this.
|
||||||
//
|
//
|
||||||
// https://github.com/julienschmidt/httprouter/issues/25#issuecomment-74977940
|
// https://github.com/julienschmidt/httprouter/issues/25#issuecomment-74977940
|
||||||
type justFilesFilesystem struct {
|
type justFilesFilesystem struct {
|
||||||
|
|
|
@ -93,7 +93,8 @@ func (app *application) SendNoContext(target, message string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
identifier := uuid.NewString()
|
identifier := uuid.NewString()
|
||||||
go app.Models.SentMessagesLogs.Insert(target, message, "unavailable", "unavailable", "unavailable", "unavailable", identifier, "unavailable")
|
go app.Models.SentMessagesLogs.Insert(
|
||||||
|
target, message, "unavailable", "unavailable", "unavailable", "unavailable", identifier, "unavailable")
|
||||||
|
|
||||||
// Since messages starting with `.` or `/` are used for special actions
|
// Since messages starting with `.` or `/` are used for special actions
|
||||||
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
||||||
|
@ -152,7 +153,8 @@ func (app *application) Send(target, message string, msgContext twitch.PrivateMe
|
||||||
|
|
||||||
commandName := strings.ToLower(strings.SplitN(msgContext.Message, " ", 3)[0][2:])
|
commandName := strings.ToLower(strings.SplitN(msgContext.Message, " ", 3)[0][2:])
|
||||||
identifier := uuid.NewString()
|
identifier := uuid.NewString()
|
||||||
go app.Models.SentMessagesLogs.Insert(target, message, commandName, msgContext.User.Name, msgContext.User.ID, msgContext.Message, identifier, msgContext.Raw)
|
go app.Models.SentMessagesLogs.Insert(
|
||||||
|
target, message, commandName, msgContext.User.Name, msgContext.User.ID, msgContext.Message, identifier, msgContext.Raw)
|
||||||
|
|
||||||
// Since messages starting with `.` or `/` are used for special actions
|
// Since messages starting with `.` or `/` are used for special actions
|
||||||
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
||||||
|
@ -209,7 +211,8 @@ func (app *application) SendNoBanphrase(target, message string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
identifier := uuid.NewString()
|
identifier := uuid.NewString()
|
||||||
go app.Models.SentMessagesLogs.Insert(target, message, "unavailable", "unavailable", "unavailable", "unavailable", identifier, "unavailable")
|
go app.Models.SentMessagesLogs.Insert(
|
||||||
|
target, message, "unavailable", "unavailable", "unavailable", "unavailable", identifier, "unavailable")
|
||||||
|
|
||||||
// Since messages starting with `.` or `/` are used for special actions
|
// Since messages starting with `.` or `/` are used for special actions
|
||||||
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
// new data.Timer struct so that the timer can be inserted into the database.
|
// new data.Timer struct so that the timer can be inserted into the database.
|
||||||
func (app *application) AddTimer(name, repeat string, message twitch.PrivateMessage) {
|
func (app *application) AddTimer(name, repeat string, message twitch.PrivateMessage) {
|
||||||
cmdParams := strings.SplitN(message.Message, " ", 500)
|
cmdParams := strings.SplitN(message.Message, " ", 500)
|
||||||
// prefixLength is the length of `()add timer` plus +2 (for the space and zero based)
|
|
||||||
prefix := "()add timer"
|
prefix := "()add timer"
|
||||||
prefixLength := len("()add timer")
|
prefixLength := len("()add timer")
|
||||||
nameLength := len(name)
|
nameLength := len(name)
|
||||||
|
@ -319,7 +318,8 @@ func (app *application) DeleteTimer(name string, message twitch.PrivateMessage)
|
||||||
app.Send(message.Channel, reply, message)
|
app.Send(message.Channel, reply, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DebugChannelTimers queries the database for all timers in channel and uploads the contents as a paste.
|
// DebugChannelTimers queries the database for all timers in channel
|
||||||
|
// and uploads the contents as a paste.
|
||||||
func (app *application) DebugChannelTimers(channel string) string {
|
func (app *application) DebugChannelTimers(channel string) string {
|
||||||
timer, err := app.Models.Timers.GetChannelTimer(channel)
|
timer, err := app.Models.Timers.GetChannelTimer(channel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -337,9 +337,8 @@ func (app *application) DebugChannelTimers(channel string) string {
|
||||||
// https://github.com/robfig/cron/issues/420#issuecomment-940949195
|
// https://github.com/robfig/cron/issues/420#issuecomment-940949195
|
||||||
i, v := i, v
|
i, v := i, v
|
||||||
_ = i
|
_ = i
|
||||||
var t string
|
|
||||||
|
|
||||||
t = fmt.Sprintf(
|
t := fmt.Sprintf(
|
||||||
"Name: \t%v\n"+
|
"Name: \t%v\n"+
|
||||||
"ID: \t%v\n"+
|
"ID: \t%v\n"+
|
||||||
"Identifier: \t%v\n"+
|
"Identifier: \t%v\n"+
|
||||||
|
@ -363,7 +362,8 @@ func (app *application) DebugChannelTimers(channel string) string {
|
||||||
return reply
|
return reply
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListchannelTimer queries the database for all timers in channel and uploads the contents as a paste.
|
// ListchannelTimer queries the database for all timers in channel and
|
||||||
|
// uploads the contents as a paste.
|
||||||
func (app *application) ListChannelTimer(channel string) string {
|
func (app *application) ListChannelTimer(channel string) string {
|
||||||
timer, err := app.Models.Timers.GetChannelTimer(channel)
|
timer, err := app.Models.Timers.GetChannelTimer(channel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -379,9 +379,8 @@ func (app *application) ListChannelTimer(channel string) string {
|
||||||
// https://github.com/robfig/cron/issues/420#issuecomment-940949195
|
// https://github.com/robfig/cron/issues/420#issuecomment-940949195
|
||||||
i, v := i, v
|
i, v := i, v
|
||||||
_ = i
|
_ = i
|
||||||
var t string
|
|
||||||
|
|
||||||
t = fmt.Sprintf(
|
t := fmt.Sprintf(
|
||||||
"Name: %v\n"+
|
"Name: %v\n"+
|
||||||
"Text: %v\n"+
|
"Text: %v\n"+
|
||||||
"Repeat: %v\n"+
|
"Repeat: %v\n"+
|
||||||
|
|
|
@ -392,7 +392,6 @@ func (app *application) YafUpload(target, path, identifier string, msg twitch.Pr
|
||||||
var reply = string(body[:])
|
var reply = string(body[:])
|
||||||
|
|
||||||
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
||||||
//app.Send(target, fmt.Sprintf("Removing file: %s", path), msg)
|
|
||||||
app.Send(target, reply, msg)
|
app.Send(target, reply, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,6 +487,5 @@ func (app *application) YafUploadString(text string) string {
|
||||||
|
|
||||||
var reply = string(body[:])
|
var reply = string(body[:])
|
||||||
|
|
||||||
//app.Send(target, fmt.Sprintf("Removing file: %s", path), msg)
|
|
||||||
return reply
|
return reply
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,8 @@ func (app *application) DebugUser(login string, message twitch.PrivateMessage) {
|
||||||
resp, err := app.uploadPaste(body)
|
resp, err := app.uploadPaste(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln("Could not upload paste:", err)
|
app.Log.Errorln("Could not upload paste:", err)
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %v", ErrDuringPasteUpload), message)
|
app.Send(message.Channel,
|
||||||
|
fmt.Sprintf("Something went wrong FeelsBadMan %v", ErrDuringPasteUpload), message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.Send(message.Channel, resp, message)
|
app.Send(message.Channel, resp, message)
|
||||||
|
@ -72,13 +73,15 @@ func (app *application) EditUserLevel(login, lvl string, message twitch.PrivateM
|
||||||
level, err := strconv.Atoi(lvl)
|
level, err := strconv.Atoi(lvl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrUserLevelNotInteger), message)
|
app.Send(message.Channel,
|
||||||
|
fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrUserLevelNotInteger), message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.Models.Users.SetLevel(login, level)
|
err = app.Models.Users.SetLevel(login, level)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
app.Send(message.Channel,
|
||||||
|
fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
@ -101,7 +104,9 @@ func (app *application) SetUserLocation(message twitch.PrivateMessage) {
|
||||||
|
|
||||||
err := app.Models.Users.SetLocation(twitchId, location)
|
err := app.Models.Users.SetLocation(twitchId, location)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
app.Send(message.Channel,
|
||||||
|
fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
||||||
|
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
@ -158,7 +163,8 @@ func (app *application) GetUserLevel(msg twitch.PrivateMessage) int {
|
||||||
// UserCheckWeather checks if a user is in the database and if he has a location
|
// UserCheckWeather checks if a user is in the database and if he has a location
|
||||||
// provided. If both is true it calls owm.Weather with the location and replies
|
// provided. If both is true it calls owm.Weather with the location and replies
|
||||||
// with the result.
|
// with the result.
|
||||||
// If no location was provided the response will instruct the user how to set a location.
|
// If no location was provided the response will instruct the user
|
||||||
|
// how to set a location.
|
||||||
func (app *application) UserCheckWeather(message twitch.PrivateMessage) {
|
func (app *application) UserCheckWeather(message twitch.PrivateMessage) {
|
||||||
target := message.Channel
|
target := message.Channel
|
||||||
twitchLogin := message.User.Name
|
twitchLogin := message.User.Name
|
||||||
|
@ -182,7 +188,8 @@ func (app *application) UserCheckWeather(message twitch.PrivateMessage) {
|
||||||
// UserCheckWeather checks if a user is in the database and if he has a lastfm
|
// UserCheckWeather checks if a user is in the database and if he has a lastfm
|
||||||
// username provided. If both is true it calls lastfm.LastFmUserRecent with the username
|
// username provided. If both is true it calls lastfm.LastFmUserRecent with the username
|
||||||
// and replies with the result.
|
// and replies with the result.
|
||||||
// If no lastfm username was provided the response will instruct the user how to set a lastfm username.
|
// If no lastfm username was provided the response will instruct the user
|
||||||
|
// how to set a lastfm username.
|
||||||
func (app *application) UserCheckLastFM(message twitch.PrivateMessage) string {
|
func (app *application) UserCheckLastFM(message twitch.PrivateMessage) string {
|
||||||
twitchLogin := message.User.Name
|
twitchLogin := message.User.Name
|
||||||
target := message.Channel
|
target := message.Channel
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -22,6 +22,7 @@ require (
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
go.uber.org/atomic v1.7.0 // indirect
|
||||||
go.uber.org/multierr v1.6.0 // indirect
|
go.uber.org/multierr v1.6.0 // indirect
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
|
honnef.co/go/tools v0.4.7 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -101,4 +101,6 @@ gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
honnef.co/go/tools v0.4.7 h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
|
||||||
|
honnef.co/go/tools v0.4.7/go.mod h1:+rnGS1THNh8zMwnd2oVOTL9QF6vmfyG6ZXBULae2uc0=
|
||||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// StrGenerateRandomNumber generates a random number from
|
// StrGenerateRandomNumber generates a random number from
|
||||||
|
@ -19,7 +18,6 @@ func StrGenerateRandomNumber(max string) int {
|
||||||
fmt.Printf("Supplied value %v is not a number", num)
|
fmt.Printf("Supplied value %v is not a number", num)
|
||||||
return 0
|
return 0
|
||||||
} else {
|
} else {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
return rand.Intn(num)
|
return rand.Intn(num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +25,6 @@ func StrGenerateRandomNumber(max string) int {
|
||||||
// GenerateRandomNumber returns a random number from
|
// GenerateRandomNumber returns a random number from
|
||||||
// a given max value as a int
|
// a given max value as a int
|
||||||
func GenerateRandomNumber(max int) int {
|
func GenerateRandomNumber(max int) int {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
return rand.Intn(max)
|
return rand.Intn(max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ func GetVersionPure() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if modified {
|
if modified {
|
||||||
return fmt.Sprintf("%s", revision)
|
return revision
|
||||||
}
|
}
|
||||||
|
|
||||||
return revision
|
return revision
|
||||||
|
|
|
@ -72,6 +72,9 @@ func IDByUsernameReply(username string) string {
|
||||||
|
|
||||||
responseList := make([]ivrResponse, 0)
|
responseList := make([]ivrResponse, 0)
|
||||||
err = json.NewDecoder(resp.Body).Decode(&responseList)
|
err = json.NewDecoder(resp.Body).Decode(&responseList)
|
||||||
|
if err != nil {
|
||||||
|
return "xd"
|
||||||
|
}
|
||||||
if len(responseList) == 0 {
|
if len(responseList) == 0 {
|
||||||
return "xd"
|
return "xd"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue