-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
Port to Funogram #59
Conversation
There was a problem hiding this 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 "") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да неужто встроенного нет!
src/VahterBanBot/Program.fs
Outdated
.AddHostedService<CleanupService>() | ||
.AddHostedService<StartupMessage>() | ||
.AddHostedService<UpdateChatAdmins>() | ||
.AddSingleton<MachineLearning>() | ||
.AddHostedService<MachineLearning>(fun sp -> sp.GetRequiredService<MachineLearning>()) | ||
// TODO[F]: Figure out these | ||
.AddHttpClient("telegram_bot_client") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а я не знаю зачем это, делал по примеру из Telegram.Bot
Может и нахер не надо
src/VahterBanBot/Program.fs
Outdated
@@ -193,22 +190,23 @@ app.UseGiraffe(webApp) | |||
let server = app.RunAsync() | |||
|
|||
// Dev mode only |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
багуля?
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я думал фунограм генерится по апи телеги?
There was a problem hiding this comment.
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, и вообще, что в документации это будет указано.
Tests: more robust logging for failed containers, destroy test container before startup
No description provided.