Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
boogiedk committed Oct 15, 2023
1 parent 6802f0f commit bdfd2af
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions SerfBot/TelegramBot.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ open SerfBot.Log
open SerfBot.Types
open SerfBot.TelegramApi

let extractCommand (str: string) = (str.Split(" ")[0]).Trim().ToLower();
let extractCommand (str: string) =
let command = (str.Split(" ")[0]).Trim().ToLower()
let userMessage = (str.Split(" ")[1]).Trim().ToLower()
(command, userMessage)

let isValidUser (userId: int64) =
if Array.contains userId Configuration.config.UserIds then Some ()
Expand All @@ -27,8 +30,7 @@ let updateArrived (ctx: UpdateContext) =
match isValidUser user.Id with
| Some () ->
logInfo $"Message from user {Option.get user.Username} received: {Option.get text}"
let userMessage = text.Value;
let command = extractCommand userMessage
let command, userMessage = extractCommand text.Value
match Commands.commandHandlers.TryGetValue command with
| true, handler ->
let replyText = handler userMessage
Expand Down

0 comments on commit bdfd2af

Please sign in to comment.