Open
Conversation
pashutk
reviewed
Nov 28, 2020
| RTE.chain(ctx => | ||
| pipe( | ||
| O.fromNullable(ctx.message), | ||
| O.chain(message => O.fromNullable(message.new_chat_members)), |
Contributor
Author
There was a problem hiding this comment.
Вообще O.mapNullable, но я понял идею
| @@ -0,0 +1,16 @@ | |||
| import * as RTE from 'fp-ts/lib/ReaderTaskEither'; | |||
Member
There was a problem hiding this comment.
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
| 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> => |
Member
There was a problem hiding this comment.
Почему unknown? посмотри че за ошибка, если не найдешь то это ну как минимум Error (но лучше найди)
Contributor
Author
There was a problem hiding this comment.
Я оч не хочу туда лезть и смотреть, потому что это раскрывает реализацию. Сегодня там одна ошибка, завтра там другая ошибка. Но unknown конечно заменю
fb5074f to
5d4888d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.