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 f90be41 commit c6ebb0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions SerfBot/OpenAiApi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ open OpenAI_API
open OpenAI_API.Models
open SerfBot.Log

let mutable currentContext = None
let defaultContext = "Ты персональный помощник-бот в telegram. Чаще всего тебе нужно генерировать C#, F# или SQL код, но иногда нужно и отвечать на бытовые вопросы."
let mutable currentContext = Some(defaultContext)

let setupContext (newContext: string) =
match newContext with
| null ->
match currentContext with
| None -> "Ты персональный помощник-бот в telegram. Чаще всего тебе нужно генерировать C#, F# или SQL код, но иногда нужно и отвечать на бытовые вопросы."
| None -> defaultContext
| Some x -> x
| _ ->
currentContext <- Some newContext
Expand Down
9 changes: 5 additions & 4 deletions SerfBot/TelegramBot.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ open SerfBot.Types
open SerfBot.TelegramApi

let extractCommand (str: string) =
let message = str.Split(" ");
let command = message[0].Trim().ToLower()
let userMessage = str.Split(" ")[1]
(command, userMessage)
match str.Split(" ", 2) with
| [| command; inputText |] ->
(command, inputText)
| [| command; |] ->
(command, null)

let isValidUser (userId: int64) =
if Array.contains userId Configuration.config.UserIds then Some ()
Expand Down

0 comments on commit c6ebb0e

Please sign in to comment.