-
Notifications
You must be signed in to change notification settings - Fork 0
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
Set bot username, refactor getting config #3
base: main
Are you sure you want to change the base?
Conversation
RTE.chain(ctx => | ||
pipe( | ||
O.fromNullable(ctx.message), | ||
O.chain(message => O.fromNullable(message.new_chat_members)), |
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.
chainNullableK
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.
Вообще O.mapNullable
, но я понял идею
@@ -0,0 +1,16 @@ | |||
import * as RTE from 'fp-ts/lib/ReaderTaskEither'; |
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.
import * as RTE from 'fp-ts/lib/ReaderTaskEither';
import { pipe } from 'fp-ts/lib/function';
import * as O from 'fp-ts/lib/Option';
import * as E from 'fp-ts/lib/Either';
import { TelegrafContext } from 'telegraf/typings/context';
import { User } from 'telegraf/typings/telegram-types';
export const newChatMembersHandler = (): RTE.ReaderTaskEither<TelegrafContext, Error, User[]> =>
pipe(
RTE.ask<TelegrafContext>(),
RTE.chainEitherK(ctx =>
pipe(
ctx.message,
O.fromNullable,
O.mapNullable(m => m.new_chat_members),
E.fromOption(() => new Error('asdf'))
)
),
RTE.chain(users => RTE.of(users))
);
tbh/src/telegram/index.ts
Outdated
import { identity } from 'fp-ts/lib/function'; | ||
import { TelegrafContext } from 'telegraf/typings/context'; | ||
|
||
export const setWebhook = (telegram: Telegram, url: string): TE.TaskEither<unknown, boolean> => | ||
TE.tryCatch(() => telegram.setWebhook(url), identity); | ||
|
||
export const getMe = (telegram: Telegram): TE.TaskEither<unknown, User> => |
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.
Почему unknown? посмотри че за ошибка, если не найдешь то это ну как минимум Error (но лучше найди)
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.
Я оч не хочу туда лезть и смотреть, потому что это раскрывает реализацию. Сегодня там одна ошибка, завтра там другая ошибка. Но unknown
конечно заменю
fb5074f
to
5d4888d
Compare
No description provided.