Skip to content

Commit

Permalink
refactor(telegram-driver): restrict event names
Browse files Browse the repository at this point in the history
  • Loading branch information
goodmind committed Nov 20, 2016
1 parent 41f5273 commit c2154a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TcombWebhookResponse, TcombRequest, TcombUpdate, TcombUpdatesState } fr
export type Token = string
export type GenericStream<T> = any
export type DriverSink = TcombRequest | TcombWebhookResponse
export type EventNames = 'message' | 'inline_query' | 'chosen_inline_result' | 'callback_query'

export interface DriverOptions {
webhook?: boolean
Expand Down
4 changes: 2 additions & 2 deletions src/telegram-driver/telegram-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
DriverExecution,
DriverSources,
DriverSink,
Token
Token, EventNames
} from '../interfaces'
import { makeSources, makeUpdates, makeWebHook } from './sources'
import { makeAPIRequest } from './api-request'
Expand All @@ -17,7 +17,7 @@ import { TcombUpdate, TcombUpdatesState, TcombWebhookResponse, TcombRequest } fr
import { adapter, isWebhookResponse, convertStream } from '../helpers'

function makeEventsSelector ({message, inlineQuery, chosenInlineResult, callbackQuery}: DriverSources) {
return function events (eventName: string): Observable<TcombUpdate> {
return function events (eventName: EventNames): Observable<TcombUpdate> {
return $.case(() => eventName, {
'message': message.share(),
'inline_query': inlineQuery.share(),
Expand Down

0 comments on commit c2154a9

Please sign in to comment.