diff --git a/chatcommands.go b/chatcommands.go index 0353cc6..56fe31e 100644 --- a/chatcommands.go +++ b/chatcommands.go @@ -127,6 +127,10 @@ var commands = &CommandControl{ title = strings.TrimSpace(title) 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 if len(link) == 0 { cl.belongsTo.AddModNotice(cl.name + " set the playing title to '" + title + "' with no link") diff --git a/settings.go b/settings.go index baaa098..fceda84 100644 --- a/settings.go +++ b/settings.go @@ -18,6 +18,7 @@ type Settings struct { filename string cmdLineKey string // stream key from the command line MaxMessageCount int + TitleLength int // maximum length of the title that can be set with the /playing AdminPassword string Bans []BanInfo StreamKey string @@ -40,6 +41,10 @@ func init() { panic("Missing stream key is settings.json") } + if settings.TitleLength <= 0 { + settings.TitleLength = 50 + } + // Save admin password to file if err = settings.Save(); err != nil { panic("Unable to save settings: " + err.Error()) diff --git a/settings_example.json b/settings_example.json index a2fbba8..3153988 100644 --- a/settings_example.json +++ b/settings_example.json @@ -1,7 +1,8 @@ { "MaxMessageCount": 300, + "TitleLength": 50, "AdminPassword": "", "Bans": [], "StreamKey": "ALongStreamKey", "ListenAddress": ":8089" -} \ No newline at end of file +}