Browse Source

Fix a bug, improve some code, add .gitignore.

master
Syfaro 1 year ago
parent
commit
a443d08111
2 changed files with 10 additions and 4 deletions
  1. 3
    0
      .gitignore
  2. 7
    4
      bot.go

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
1
+*.db
2
+*.lock
3
+telegram-previous-images*

+ 7
- 4
bot.go View File

@@ -215,14 +215,17 @@ func (cmd handleThreshold) Execute(msg tgbotapi.Message) error {
215 215
 			return err
216 216
 		}
217 217
 
218
-		arg := strings.Fields(msg.CommandArguments())[0]
218
+		args := strings.Fields(msg.CommandArguments())
219
+		if len(args) != 1 {
220
+			return cmd.QuickReply(msg, "You must include the threshold value")
221
+		}
222
+		arg := args[0]
219 223
 
220 224
 		if _, err := strconv.Atoi(arg); err != nil {
221 225
 			return cmd.QuickReply(msg, "Your threshold must be a number")
222 226
 		}
223 227
 
224
-		err = b.Put([]byte(strconv.FormatInt(msg.Chat.ID, 10)), []byte(arg))
225
-		if err != nil {
228
+		if err = b.Put([]byte(strconv.FormatInt(msg.Chat.ID, 10)), []byte(arg)); err != nil {
226 229
 			return err
227 230
 		}
228 231
 
@@ -278,7 +281,7 @@ func main() {
278 281
 	}
279 282
 
280 283
 	bot := finch.NewFinch(os.Getenv("TELEGRAM_APITOKEN"))
281
-	//bot.API.Debug = true
284
+	bot.API.Debug = os.Getenv("TELEGRAM_DEBUG") == "true"
282 285
 
283 286
 	bot.Start()
284 287
 }

Loading…
Cancel
Save