Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Funogram #59

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Port to Funogram #59

wants to merge 8 commits into from

Conversation

ForNeVeR
Copy link
Member

No description provided.

Copy link
Contributor

@Szer Szer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Очень хорошо! Мне нравится

(botConfig: BotConfiguration)
(logger: ILogger)
(callbackQuery: CallbackQuery) = task {
use onCallbackActivity = botActivity.StartActivity("onCallback")
%onCallbackActivity.SetTag("callbackId", callbackQuery.Data)

let callbackId = Guid.Parse callbackQuery.Data
let callbackId = Guid.Parse(callbackQuery.Data |> Option.defaultValue "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я бы предложил с грохотом упать если у нас не callbackQuery.Data.
Оно конечно и так упадёт, ноу же с ошибкой парсинга гуида, что чуть менее понятно

module internal Converters =
open Funogram.StringUtils

let private unixEpoch = DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да неужто встроенного нет!

.AddHostedService<CleanupService>()
.AddHostedService<StartupMessage>()
.AddHostedService<UpdateChatAdmins>()
.AddSingleton<MachineLearning>()
.AddHostedService<MachineLearning>(fun sp -> sp.GetRequiredService<MachineLearning>())
// TODO[F]: Figure out these
.AddHttpClient("telegram_bot_client")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а я не знаю зачем это, делал по примеру из Telegram.Bot

Может и нахер не надо

@@ -193,22 +190,23 @@ app.UseGiraffe(webApp)
let server = app.RunAsync()

// Dev mode only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я б удалил в целом, это Кирилл для дебага делал, но я хз.

В целом есть планы перейти на полноценный поллинг, но он не так будет выглядеть

match s with
| None -> null
| Some s when s.StartsWith "@" -> s
| Some s -> s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

багуля?

Suggested change
| Some s -> s
| Some s -> "@" + s

|> Option.orElse msg.Caption
|> Option.defaultValue ""

member msg.MessageId32 = // the documentation guarantees that this always fits into int32, Funogram disagrees
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я думал фунограм генерится по апи телеги?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У них в документации Type всегда Integer. Для некоторых типов в документации указано:

Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.

Я решил, что безопаснее везде использовать int64, чем надеяться на то, что генератор корректно определит тип на основе desciption, и вообще, что в документации это будет указано.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants