mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add user level restrictions to commands
This commit is contained in:
parent
d6bdc0ca1a
commit
2860732011
|
@ -37,6 +37,7 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
msgLen := len(strings.SplitN(message.Message, " ", -2))
|
msgLen := len(strings.SplitN(message.Message, " ", -2))
|
||||||
|
|
||||||
userLevel := app.GetUserLevel(message.User.ID)
|
userLevel := app.GetUserLevel(message.User.ID)
|
||||||
|
|
||||||
// target is the channelname the message originated from and
|
// target is the channelname the message originated from and
|
||||||
// where the TwitchClient should send the response
|
// where the TwitchClient should send the response
|
||||||
target := message.Channel
|
target := message.Channel
|
||||||
|
@ -63,7 +64,9 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
if msgLen == 1 {
|
if msgLen == 1 {
|
||||||
reply = "xd"
|
reply = "xd"
|
||||||
}
|
}
|
||||||
|
// --------------------------------
|
||||||
|
// pleb commands
|
||||||
|
// --------------------------------
|
||||||
case "bttv":
|
case "bttv":
|
||||||
if msgLen < 2 {
|
if msgLen < 2 {
|
||||||
reply = "Not enough arguments provided. Usage: ()bttv <emote name>"
|
reply = "Not enough arguments provided. Usage: ()bttv <emote name>"
|
||||||
|
@ -87,18 +90,6 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
reply, _ = commands.Currency(cmdParams[1], cmdParams[2], cmdParams[4])
|
reply, _ = commands.Currency(cmdParams[1], cmdParams[2], cmdParams[4])
|
||||||
}
|
}
|
||||||
|
|
||||||
case "catbox":
|
|
||||||
go app.NewDownload("catbox", target, cmdParams[1], message)
|
|
||||||
|
|
||||||
case "kappa":
|
|
||||||
go app.NewDownload("kappa", target, cmdParams[1], message)
|
|
||||||
|
|
||||||
case "yaf":
|
|
||||||
go app.NewDownload("yaf", target, cmdParams[1], message)
|
|
||||||
|
|
||||||
case "gofile":
|
|
||||||
go app.NewDownload("gofile", target, cmdParams[1], message)
|
|
||||||
|
|
||||||
case "osrs":
|
case "osrs":
|
||||||
reply = commands.OSRS(message.Message[7:len(message.Message)])
|
reply = commands.OSRS(message.Message[7:len(message.Message)])
|
||||||
|
|
||||||
|
@ -132,9 +123,6 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
case "7tv":
|
case "7tv":
|
||||||
reply = commands.SevenTV(cmdParams[1])
|
reply = commands.SevenTV(cmdParams[1])
|
||||||
|
|
||||||
case "mail":
|
|
||||||
app.SendEmail("Test command used!", "This is an email test")
|
|
||||||
|
|
||||||
case "lastfm":
|
case "lastfm":
|
||||||
if msgLen == 1 {
|
if msgLen == 1 {
|
||||||
reply = app.UserCheckLastFM(message)
|
reply = app.UserCheckLastFM(message)
|
||||||
|
@ -172,8 +160,6 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
reply, _ = commands.Weather(message.Message[10:len(message.Message)])
|
reply, _ = commands.Weather(message.Message[10:len(message.Message)])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Xkcd
|
|
||||||
// Random Xkcd
|
|
||||||
case "rxkcd":
|
case "rxkcd":
|
||||||
reply, _ = commands.RandomXkcd()
|
reply, _ = commands.RandomXkcd()
|
||||||
case "randomxkcd":
|
case "randomxkcd":
|
||||||
|
@ -182,18 +168,21 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
case "xkcd":
|
case "xkcd":
|
||||||
reply, _ = commands.Xkcd()
|
reply, _ = commands.Xkcd()
|
||||||
|
|
||||||
case "timer":
|
case "uid":
|
||||||
|
reply = ivr.IDByUsername(cmdParams[1])
|
||||||
|
|
||||||
|
case "set":
|
||||||
switch cmdParams[1] {
|
switch cmdParams[1] {
|
||||||
case "add":
|
case "lastfm":
|
||||||
app.AddTimer(cmdParams[2], cmdParams[3], message)
|
app.SetUserLastFM(cmdParams[2], message)
|
||||||
case "edit":
|
case "location":
|
||||||
app.EditTimer(cmdParams[2], cmdParams[3], message)
|
app.SetUserLocation(message)
|
||||||
case "delete":
|
|
||||||
app.DeleteTimer(cmdParams[2], message)
|
|
||||||
case "list":
|
|
||||||
reply = app.ListTimers()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------
|
||||||
|
// 250 user level
|
||||||
|
// --------------------------------
|
||||||
|
|
||||||
case "debug":
|
case "debug":
|
||||||
switch cmdParams[1] {
|
switch cmdParams[1] {
|
||||||
case "user":
|
case "user":
|
||||||
|
@ -206,27 +195,83 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "command":
|
case "timer":
|
||||||
switch cmdParams[1] {
|
switch cmdParams[1] {
|
||||||
case "add":
|
case "add":
|
||||||
app.AddCommand(cmdParams[2], message)
|
if userLevel >= 250 {
|
||||||
case "delete":
|
app.AddTimer(cmdParams[2], cmdParams[3], message)
|
||||||
app.DeleteCommand(cmdParams[2], message)
|
}
|
||||||
case "edit":
|
case "edit":
|
||||||
switch cmdParams[2] {
|
if userLevel >= 250 {
|
||||||
case "level":
|
app.EditTimer(cmdParams[2], cmdParams[3], message)
|
||||||
app.EditCommandLevel(cmdParams[3], cmdParams[4], message)
|
}
|
||||||
case "category":
|
case "delete":
|
||||||
app.EditCommandCategory(cmdParams[3], cmdParams[4], message)
|
if userLevel >= 250 {
|
||||||
|
app.DeleteTimer(cmdParams[2], message)
|
||||||
|
}
|
||||||
|
case "list":
|
||||||
|
if userLevel >= 250 {
|
||||||
|
reply = app.ListTimers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "set":
|
case "command":
|
||||||
switch cmdParams[1] {
|
switch cmdParams[1] {
|
||||||
case "lastfm":
|
case "add":
|
||||||
app.SetUserLastFM(cmdParams[2], message)
|
if userLevel >= 250 {
|
||||||
case "location":
|
app.AddCommand(cmdParams[2], message)
|
||||||
app.SetUserLocation(message)
|
}
|
||||||
|
case "delete":
|
||||||
|
if userLevel >= 250 {
|
||||||
|
app.DeleteCommand(cmdParams[2], message)
|
||||||
|
}
|
||||||
|
case "edit":
|
||||||
|
switch cmdParams[2] {
|
||||||
|
case "level":
|
||||||
|
if userLevel >= 250 {
|
||||||
|
app.EditCommandLevel(cmdParams[3], cmdParams[4], message)
|
||||||
|
}
|
||||||
|
case "category":
|
||||||
|
if userLevel >= 250 {
|
||||||
|
app.EditCommandCategory(cmdParams[3], cmdParams[4], message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------
|
||||||
|
// 500 User Level
|
||||||
|
//---------------------------------
|
||||||
|
case "catbox":
|
||||||
|
if userLevel >= 500 {
|
||||||
|
go app.NewDownload("catbox", target, cmdParams[1], message)
|
||||||
|
}
|
||||||
|
|
||||||
|
case "kappa":
|
||||||
|
if userLevel >= 500 {
|
||||||
|
go app.NewDownload("kappa", target, cmdParams[1], message)
|
||||||
|
}
|
||||||
|
|
||||||
|
case "yaf":
|
||||||
|
if userLevel >= 500 {
|
||||||
|
go app.NewDownload("yaf", target, cmdParams[1], message)
|
||||||
|
}
|
||||||
|
|
||||||
|
case "gofile":
|
||||||
|
if userLevel >= 500 {
|
||||||
|
go app.NewDownload("gofile", target, cmdParams[1], message)
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------
|
||||||
|
// 1000 User Level
|
||||||
|
//------------------------------------
|
||||||
|
case "join":
|
||||||
|
if userLevel >= 1000 {
|
||||||
|
go app.AddChannel(cmdParams[1], message)
|
||||||
|
}
|
||||||
|
|
||||||
|
case "part":
|
||||||
|
if userLevel >= 1000 {
|
||||||
|
go app.DeleteChannel(cmdParams[1], message)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "user":
|
case "user":
|
||||||
|
@ -234,19 +279,19 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
case "edit":
|
case "edit":
|
||||||
switch cmdParams[2] {
|
switch cmdParams[2] {
|
||||||
case "level":
|
case "level":
|
||||||
app.EditUserLevel(cmdParams[3], cmdParams[4], message)
|
if userLevel >= 1000 {
|
||||||
|
app.EditUserLevel(cmdParams[3], cmdParams[4], message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "set":
|
||||||
|
switch cmdParams[2] {
|
||||||
|
case "level":
|
||||||
|
if userLevel >= 1000 {
|
||||||
|
app.EditUserLevel(cmdParams[3], cmdParams[4], message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "join":
|
|
||||||
go app.AddChannel(cmdParams[1], message)
|
|
||||||
|
|
||||||
case "part":
|
|
||||||
go app.DeleteChannel(cmdParams[1], message)
|
|
||||||
|
|
||||||
case "uid":
|
|
||||||
reply = ivr.IDByUsername(cmdParams[1])
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
r, err := app.GetCommand(target, commandName, userLevel)
|
r, err := app.GetCommand(target, commandName, userLevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue