mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
fix comments
This commit is contained in:
parent
74b4ac2962
commit
4374119f4c
4 changed files with 19 additions and 21 deletions
|
@ -9,9 +9,9 @@ import (
|
|||
"github.com/lyx0/nourybot/pkg/common"
|
||||
)
|
||||
|
||||
// AddChannel takes in a channel name, then queries `GetIdByLogin` for the
|
||||
// AddChannel takes in a channel name, then calls GetIdByLogin for the
|
||||
// channels ID and inserts both the name and id value into the database.
|
||||
// If there was no error thrown the `app.TwitchClient` joins the channel afterwards.
|
||||
// If there is no error thrown the TwitchClient joins the channel afterwards.
|
||||
func (app *Application) AddChannel(login string, message twitch.PrivateMessage) {
|
||||
userId, err := decapi.GetIdByLogin(login)
|
||||
if err != nil {
|
||||
|
@ -20,7 +20,7 @@ func (app *Application) AddChannel(login string, message twitch.PrivateMessage)
|
|||
}
|
||||
|
||||
// Initialize a new channel struct holding the values that will be
|
||||
// passed into the `app.Models.Channels.Insert()` method.
|
||||
// passed into the app.Models.Channels.Insert() method.
|
||||
channel := &data.Channel{
|
||||
Login: login,
|
||||
TwitchID: userId,
|
||||
|
@ -67,17 +67,17 @@ func (app *Application) DeleteChannel(login string, message twitch.PrivateMessag
|
|||
common.Send(message.Channel, reply, app.TwitchClient)
|
||||
}
|
||||
|
||||
// InitialJoin is called on startup and gets all the channels from the database
|
||||
// so that the `app.TwitchClient` then joins each.
|
||||
// InitialJoin is called on startup and queries the database for a list of
|
||||
// channels which the TwitchClient then joins.
|
||||
func (app *Application) InitialJoin() {
|
||||
// GetJoinable returns a `[]string` containing the channel names.
|
||||
// GetJoinable returns a slice of channel names.
|
||||
channel, err := app.Models.Channels.GetJoinable()
|
||||
if err != nil {
|
||||
app.Logger.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Iterate over the `[]string` and join each.
|
||||
// Iterate over the slice of channels and join each.
|
||||
for _, v := range channel {
|
||||
app.TwitchClient.Join(v)
|
||||
app.Logger.Infow("Joining channel:",
|
||||
|
|
|
@ -33,7 +33,7 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
|||
msgLen := len(strings.SplitN(message.Message, " ", -2))
|
||||
|
||||
// target is the channelname the message originated from and
|
||||
// where we are responding.
|
||||
// where the TwitchClient should send the response
|
||||
target := message.Channel
|
||||
|
||||
// Userlevel is the level set for a user in the database.
|
||||
|
@ -45,7 +45,6 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
|||
// If the level returned is 0 then the user was not found in the database.
|
||||
userLevel := app.GetUserLevel(message.User.Name)
|
||||
|
||||
// Left in for debugging purposes.
|
||||
app.Logger.Infow("Command received",
|
||||
// "message", message, // Pretty taxing
|
||||
"message.Message", message.Message,
|
||||
|
@ -60,8 +59,8 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
|||
// Hardcoded commands have a priority over database commands.
|
||||
// Switch over the commandName and see if there is a hardcoded case for it.
|
||||
// If there was no switch case satisfied, query the database if there is
|
||||
// a `data.CommandModel.Name` equal to the `commandName`
|
||||
// If there is return the `data.CommandModel.Text` entry.
|
||||
// a data.CommandModel.Name equal to the `commandName`
|
||||
// If there is return the data.CommandModel.Text entry.
|
||||
// Otherwise we ignore the message.
|
||||
switch commandName {
|
||||
case "":
|
||||
|
@ -149,6 +148,7 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
|||
return
|
||||
}
|
||||
|
||||
// ()pinG
|
||||
case "ping":
|
||||
commands.Ping(target, app.TwitchClient)
|
||||
return
|
||||
|
@ -232,6 +232,7 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
|||
return
|
||||
}
|
||||
|
||||
// ()echo <message>
|
||||
case "echo":
|
||||
if userLevel < 250 { // Limit to myself for now.
|
||||
return
|
||||
|
@ -244,7 +245,7 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
|||
}
|
||||
|
||||
//###################
|
||||
// 1000- Admin only
|
||||
// 1000 - Admin only
|
||||
//###################
|
||||
|
||||
// #####
|
||||
|
@ -367,7 +368,6 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
|||
}
|
||||
|
||||
// ##################
|
||||
// Database Command
|
||||
// Check if the commandName exists as the "name" of a command in the database.
|
||||
// if it doesnt then ignore it.
|
||||
// ##################
|
||||
|
|
|
@ -33,7 +33,6 @@ func (app *Application) AddCommand(name string, message twitch.PrivateMessage) {
|
|||
common.Send(message.Channel, reply, app.TwitchClient)
|
||||
return
|
||||
} else {
|
||||
|
||||
reply := fmt.Sprintf("Successfully added command: %s", name)
|
||||
common.Send(message.Channel, reply, app.TwitchClient)
|
||||
return
|
||||
|
@ -73,7 +72,6 @@ func (app *Application) GetCommand(name, username string) (string, error) {
|
|||
|
||||
// Userlevel was not enough so return an empty string and error.
|
||||
return "", ErrUserInsufficientLevel
|
||||
|
||||
}
|
||||
|
||||
// EditCommandLevel takes in a name and level string and updates the entry with name
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"github.com/lyx0/nourybot/pkg/common"
|
||||
)
|
||||
|
||||
// AddUser takes in a login and level string. It calls GetIdByLogin to get the twitch id
|
||||
// of the login name and then adds the login name, twitch id and supplied level to the database.
|
||||
// AddUser calls GetIdByLogin to get the twitch id of the login name and then adds
|
||||
// the login name, twitch id and supplied level to the database.
|
||||
func (app *Application) AddUser(login, lvl string, message twitch.PrivateMessage) {
|
||||
userId, err := decapi.GetIdByLogin(login)
|
||||
if err != nil {
|
||||
|
@ -65,8 +65,8 @@ func (app *Application) DebugUser(login string, message twitch.PrivateMessage) {
|
|||
}
|
||||
}
|
||||
|
||||
// DeleteUser takes in a login string, queries the database for such a name and if an
|
||||
// entry for the name exists deletes the entry.
|
||||
// DeleteUser takes in a login string, queries the database for an entry with
|
||||
// that login name and tries to delete that entry in the database.
|
||||
func (app *Application) DeleteUser(login string, message twitch.PrivateMessage) {
|
||||
err := app.Models.Users.Delete(login)
|
||||
if err != nil {
|
||||
|
@ -79,8 +79,8 @@ func (app *Application) DeleteUser(login string, message twitch.PrivateMessage)
|
|||
common.Send(message.Channel, reply, app.TwitchClient)
|
||||
}
|
||||
|
||||
// EditUserLevel takes in a login name and level string, then updates the database record
|
||||
// for the login name with the new level if such an entry exists.
|
||||
// EditUserLevel tries to update the database record for the supplied
|
||||
// login name with the new level.
|
||||
func (app *Application) EditUserLevel(login, lvl string, message twitch.PrivateMessage) {
|
||||
// Convert the level string to an integer. This is an easy check to see if
|
||||
// the level supplied was a number only.
|
||||
|
|
Loading…
Reference in a new issue