Add a limit to the title length
Added a limit to how long the title can be when set from the /playing command. The default value is 50 if it is not in the settings file or if the value in the settings is below zero. Resolves #43
This commit is contained in:
parent
7dff29b152
commit
b30202441a
|
@ -127,6 +127,10 @@ var commands = &CommandControl{
|
||||||
title = strings.TrimSpace(title)
|
title = strings.TrimSpace(title)
|
||||||
link = strings.TrimSpace(link)
|
link = strings.TrimSpace(link)
|
||||||
|
|
||||||
|
if len(title) > settings.TitleLength {
|
||||||
|
return fmt.Sprintf("Title too long (%d/%d)", len(title), settings.TitleLength)
|
||||||
|
}
|
||||||
|
|
||||||
// Send a notice to the mods and admins
|
// Send a notice to the mods and admins
|
||||||
if len(link) == 0 {
|
if len(link) == 0 {
|
||||||
cl.belongsTo.AddModNotice(cl.name + " set the playing title to '" + title + "' with no link")
|
cl.belongsTo.AddModNotice(cl.name + " set the playing title to '" + title + "' with no link")
|
||||||
|
|
|
@ -18,6 +18,7 @@ type Settings struct {
|
||||||
filename string
|
filename string
|
||||||
cmdLineKey string // stream key from the command line
|
cmdLineKey string // stream key from the command line
|
||||||
MaxMessageCount int
|
MaxMessageCount int
|
||||||
|
TitleLength int // maximum length of the title that can be set with the /playing
|
||||||
AdminPassword string
|
AdminPassword string
|
||||||
Bans []BanInfo
|
Bans []BanInfo
|
||||||
StreamKey string
|
StreamKey string
|
||||||
|
@ -40,6 +41,10 @@ func init() {
|
||||||
panic("Missing stream key is settings.json")
|
panic("Missing stream key is settings.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if settings.TitleLength <= 0 {
|
||||||
|
settings.TitleLength = 50
|
||||||
|
}
|
||||||
|
|
||||||
// Save admin password to file
|
// Save admin password to file
|
||||||
if err = settings.Save(); err != nil {
|
if err = settings.Save(); err != nil {
|
||||||
panic("Unable to save settings: " + err.Error())
|
panic("Unable to save settings: " + err.Error())
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"MaxMessageCount": 300,
|
"MaxMessageCount": 300,
|
||||||
|
"TitleLength": 50,
|
||||||
"AdminPassword": "",
|
"AdminPassword": "",
|
||||||
"Bans": [],
|
"Bans": [],
|
||||||
"StreamKey": "ALongStreamKey",
|
"StreamKey": "ALongStreamKey",
|
||||||
"ListenAddress": ":8089"
|
"ListenAddress": ":8089"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue