From b118fbd47796aba1d8b92563ea6a297df9367591 Mon Sep 17 00:00:00 2001 From: Luther Wen Xu Date: Wed, 16 Oct 2019 12:40:26 +0800 Subject: [PATCH] go: discord/modules: Set limit for validation code length --- GoBot/discord/config/translate.go | 1 + GoBot/discord/modules/invite.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/GoBot/discord/config/translate.go b/GoBot/discord/config/translate.go index 1c94702..b08c37b 100644 --- a/GoBot/discord/config/translate.go +++ b/GoBot/discord/config/translate.go @@ -82,6 +82,7 @@ const InviteSuccessNew = "这个验证码现在属于你了。请好好保管并 const InviteSuccessAlreadyOwn = "该验证码原本就已经属于你。请直接交给你要邀请的人吧。\nThe validation code already belongs to you. You can pass it on to a user you want to invite." const ErrorInviteTitle = "制造验证码失败 Create Validation Code Error" const ErrorInviteCodeContainsSpace = "所制造的验证码不得有任何空格。\nThe validation code to create cannot contain any spaces." +const ErrorInviteCodeTooLong = "所制造的验证码必须少于512个字符。\nThe validation code cannot be longer than 512 characters." const ErrorInviteOwnedByOthers = "这个验证码已被其他会员注册。请使用别的验证码。\nThis validation code is already registered. Please try another one." const ErrorInviteExistAndUsed = "这个验证码已被使用过。请使用别的验证码。\nThis validation code has already been used. Please try another one." diff --git a/GoBot/discord/modules/invite.go b/GoBot/discord/modules/invite.go index 1e09c6f..5c15658 100644 --- a/GoBot/discord/modules/invite.go +++ b/GoBot/discord/modules/invite.go @@ -25,6 +25,11 @@ var createInvite = enforceDM(memberFilter(true, enforceArgumentCount( Send(s, m.ChannelID) return } + if len(command[1]) > 512 { + message.InitNewEmbed(config.ErrorInviteTitle, config.ErrorInviteCodeTooLong, config.ErrorColour). + Send(s, m.ChannelID) + return + } err := db.SetInviteOwner(command[1], m.Author.ID) switch err {