@tgify/tgify 0.1.0 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +23 -23
  2. package/README.md +356 -356
  3. package/lib/cli.mjs +9 -9
  4. package/package.json +1 -1
  5. package/src/button.ts +182 -182
  6. package/src/composer.ts +1008 -1008
  7. package/src/context.ts +1661 -1661
  8. package/src/core/helpers/args.ts +63 -63
  9. package/src/core/helpers/check.ts +71 -71
  10. package/src/core/helpers/compact.ts +18 -18
  11. package/src/core/helpers/deunionize.ts +26 -26
  12. package/src/core/helpers/formatting.ts +119 -119
  13. package/src/core/helpers/util.ts +96 -96
  14. package/src/core/network/client.ts +396 -396
  15. package/src/core/network/error.ts +29 -29
  16. package/src/core/network/multipart-stream.ts +45 -45
  17. package/src/core/network/polling.ts +94 -94
  18. package/src/core/network/webhook.ts +58 -58
  19. package/src/core/types/typegram.ts +54 -54
  20. package/src/filters.ts +109 -109
  21. package/src/format.ts +110 -110
  22. package/src/future.ts +213 -213
  23. package/src/index.ts +17 -17
  24. package/src/input.ts +59 -59
  25. package/src/markup.ts +142 -142
  26. package/src/middleware.ts +24 -24
  27. package/src/reactions.ts +118 -118
  28. package/src/router.ts +55 -55
  29. package/src/scenes/base.ts +52 -52
  30. package/src/scenes/context.ts +136 -136
  31. package/src/scenes/index.ts +21 -21
  32. package/src/scenes/stage.ts +71 -71
  33. package/src/scenes/wizard/context.ts +58 -58
  34. package/src/scenes/wizard/index.ts +63 -63
  35. package/src/scenes.ts +1 -1
  36. package/src/session.ts +204 -204
  37. package/src/telegraf.ts +354 -354
  38. package/src/telegram-types.ts +219 -219
  39. package/src/telegram.ts +1635 -1635
  40. package/src/types.ts +2 -2
  41. package/src/utils.ts +1 -1
  42. package/typings/telegraf.d.ts.map +1 -1
@@ -1,96 +1,96 @@
1
- import { FmtString } from './formatting'
2
- import { Deunionize, UnionKeys } from './deunionize'
3
-
4
- export const env = process.env
5
-
6
- // eslint-disable-next-line @typescript-eslint/ban-types
7
- export type Any = {} | undefined | null
8
-
9
- export type Expand<T> = T extends object
10
- ? T extends infer O
11
- ? { [K in keyof O]: O[K] }
12
- : never
13
- : T
14
-
15
- export type MaybeArray<T> = T | T[]
16
- export type MaybePromise<T> = T | Promise<T>
17
- export type NonemptyReadonlyArray<T> = readonly [T, ...T[]]
18
-
19
- // prettier-ignore
20
- export type ExclusiveKeys<A extends object, B extends object> = keyof Omit<A, keyof B>
21
-
22
- export function fmtCaption<
23
- Extra extends { caption?: string | FmtString } | undefined,
24
- >(
25
- extra?: Extra
26
- ): Extra extends undefined
27
- ? undefined
28
- : Omit<Extra, 'caption'> & { caption?: string }
29
-
30
- export function fmtCaption(extra?: { caption?: string | FmtString }) {
31
- if (!extra) return
32
- const caption = extra.caption
33
- if (!caption || typeof caption === 'string') return extra
34
- const { text, entities } = caption
35
- return {
36
- ...extra,
37
- caption: text,
38
- ...(entities && {
39
- caption_entities: entities,
40
- parse_mode: undefined,
41
- }),
42
- }
43
- }
44
-
45
- export type DistinctKeys<T extends object> = Exclude<UnionKeys<T>, keyof T>
46
-
47
- // prettier-ignore
48
- /* eslint-disable-next-line @typescript-eslint/ban-types */
49
- export type KeyedDistinct<T extends object, K extends DistinctKeys<T>> = Record<K, {}> & Deunionize<Record<K, {}>, T>
50
-
51
- // prettier-ignore
52
- /* eslint-disable-next-line @typescript-eslint/ban-types */
53
- export type Keyed<T extends object, K extends UnionKeys<T>> = Record<K, {}> & Deunionize<Record<K, {}>, T>
54
-
55
- /** Construct a generic type guard */
56
- export type Guard<X = unknown, Y extends X = X> = (x: X) => x is Y
57
-
58
- /** Extract the guarded type from a type guard, defaults to never. */
59
- export type Guarded<F> =
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- F extends (x: any) => x is infer T ? T : never
62
-
63
- export function* zip<X, Y>(xs: Iterable<X>, ys: Iterable<Y>): Iterable<X | Y> {
64
- const x = xs[Symbol.iterator]()
65
- const y = ys[Symbol.iterator]()
66
- let x1 = x.next()
67
- let y1 = y.next()
68
-
69
- while (!x1.done) {
70
- yield x1.value
71
- if (!y1.done) yield y1.value
72
- x1 = x.next()
73
- y1 = y.next()
74
- }
75
-
76
- while (!y1.done) {
77
- yield y1.value
78
- y1 = y.next()
79
- }
80
- }
81
-
82
- export function indexed<T extends object, U>(
83
- target: T,
84
- indexer: (index: number) => U
85
- ) {
86
- return new Proxy(target, {
87
- get: function (target, prop, receiver) {
88
- if (
89
- (typeof prop === 'string' || typeof prop === 'number') &&
90
- !isNaN(+prop)
91
- )
92
- return indexer.call(target, +prop)
93
- return Reflect.get(target, prop, receiver)
94
- },
95
- })
96
- }
1
+ import { FmtString } from './formatting'
2
+ import { Deunionize, UnionKeys } from './deunionize'
3
+
4
+ export const env = process.env
5
+
6
+ // eslint-disable-next-line @typescript-eslint/ban-types
7
+ export type Any = {} | undefined | null
8
+
9
+ export type Expand<T> = T extends object
10
+ ? T extends infer O
11
+ ? { [K in keyof O]: O[K] }
12
+ : never
13
+ : T
14
+
15
+ export type MaybeArray<T> = T | T[]
16
+ export type MaybePromise<T> = T | Promise<T>
17
+ export type NonemptyReadonlyArray<T> = readonly [T, ...T[]]
18
+
19
+ // prettier-ignore
20
+ export type ExclusiveKeys<A extends object, B extends object> = keyof Omit<A, keyof B>
21
+
22
+ export function fmtCaption<
23
+ Extra extends { caption?: string | FmtString } | undefined,
24
+ >(
25
+ extra?: Extra
26
+ ): Extra extends undefined
27
+ ? undefined
28
+ : Omit<Extra, 'caption'> & { caption?: string }
29
+
30
+ export function fmtCaption(extra?: { caption?: string | FmtString }) {
31
+ if (!extra) return
32
+ const caption = extra.caption
33
+ if (!caption || typeof caption === 'string') return extra
34
+ const { text, entities } = caption
35
+ return {
36
+ ...extra,
37
+ caption: text,
38
+ ...(entities && {
39
+ caption_entities: entities,
40
+ parse_mode: undefined,
41
+ }),
42
+ }
43
+ }
44
+
45
+ export type DistinctKeys<T extends object> = Exclude<UnionKeys<T>, keyof T>
46
+
47
+ // prettier-ignore
48
+ /* eslint-disable-next-line @typescript-eslint/ban-types */
49
+ export type KeyedDistinct<T extends object, K extends DistinctKeys<T>> = Record<K, {}> & Deunionize<Record<K, {}>, T>
50
+
51
+ // prettier-ignore
52
+ /* eslint-disable-next-line @typescript-eslint/ban-types */
53
+ export type Keyed<T extends object, K extends UnionKeys<T>> = Record<K, {}> & Deunionize<Record<K, {}>, T>
54
+
55
+ /** Construct a generic type guard */
56
+ export type Guard<X = unknown, Y extends X = X> = (x: X) => x is Y
57
+
58
+ /** Extract the guarded type from a type guard, defaults to never. */
59
+ export type Guarded<F> =
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ F extends (x: any) => x is infer T ? T : never
62
+
63
+ export function* zip<X, Y>(xs: Iterable<X>, ys: Iterable<Y>): Iterable<X | Y> {
64
+ const x = xs[Symbol.iterator]()
65
+ const y = ys[Symbol.iterator]()
66
+ let x1 = x.next()
67
+ let y1 = y.next()
68
+
69
+ while (!x1.done) {
70
+ yield x1.value
71
+ if (!y1.done) yield y1.value
72
+ x1 = x.next()
73
+ y1 = y.next()
74
+ }
75
+
76
+ while (!y1.done) {
77
+ yield y1.value
78
+ y1 = y.next()
79
+ }
80
+ }
81
+
82
+ export function indexed<T extends object, U>(
83
+ target: T,
84
+ indexer: (index: number) => U
85
+ ) {
86
+ return new Proxy(target, {
87
+ get: function (target, prop, receiver) {
88
+ if (
89
+ (typeof prop === 'string' || typeof prop === 'number') &&
90
+ !isNaN(+prop)
91
+ )
92
+ return indexer.call(target, +prop)
93
+ return Reflect.get(target, prop, receiver)
94
+ },
95
+ })
96
+ }