deno.land / x / grammy@v1.22.4 / convenience / constants.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { DEFAULT_UPDATE_TYPES } from "../bot.ts";
const ALL_UPDATE_TYPES = [ ...DEFAULT_UPDATE_TYPES, "chat_member", "message_reaction", "message_reaction_count",] as const;const ALL_CHAT_PERMISSIONS = { is_anonymous: true, can_manage_chat: true, can_delete_messages: true, can_manage_video_chats: true, can_restrict_members: true, can_promote_members: true, can_change_info: true, can_invite_users: true, can_post_stories: true, can_edit_stories: true, can_delete_stories: true, can_post_messages: true, can_edit_messages: true, can_pin_messages: true, can_manage_topics: true,} as const;
/** * Types of the constants used in the Telegram Bot API. Currently holds all * available update types as well as all chat permissions. */export interface ApiConstants { /** * List of update types a bot receives by default. Useful if you want to * receive all update types but `chat_member`. * * ```ts * // Built-in polling: * bot.start({ allowed_updates: DEFAULT_UPDATE_TYPES }); * // grammY runner: * run(bot, { runner: { fetch: { allowed_updates: DEFAULT_UPDATE_TYPES } } }); * // Webhooks: * await bot.api.setWebhook(url, { allowed_updates: DEFAULT_UPDATE_TYPES }); * ``` * * See the [Bot API reference](https://core.telegram.org/bots/api#update) * for more information. */ DEFAULT_UPDATE_TYPES: typeof DEFAULT_UPDATE_TYPES[number];
/** * List of all available update types. Useful if you want to receive all * updates from the Bot API, rather than just those that are delivered by * default. * * The main use case for this is when you want to receive `chat_member` * updates, as they need to be enabled first. Use it like so: * * ```ts * // Built-in polling: * bot.start({ allowed_updates: ALL_UPDATE_TYPES }); * // grammY runner: * run(bot, { runner: { fetch: { allowed_updates: ALL_UPDATE_TYPES } } }); * // Webhooks: * await bot.api.setWebhook(url, { allowed_updates: ALL_UPDATE_TYPES }); * ``` * * See the [Bot API reference](https://core.telegram.org/bots/api#update) * for more information. */ ALL_UPDATE_TYPES: typeof ALL_UPDATE_TYPES[number];
/** * An object containing all available chat permissions. Useful if you want * to lift restrictions from a user, as this action requires you to pass * `true` for all permissions. Use it like so: * * ```ts * // On `Bot`: * await bot.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS); * // On `Api`: * await ctx.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS); * // On `Context`: * await ctx.restrictChatMember(user_id, ALL_CHAT_PERMISSIONS); * await ctx.restrictAuthor(ALL_CHAT_PERMISSIONS); * ``` * * See the [Bot API reference](https://core.telegram.org/bots/api#update) * for more information. */ ALL_CHAT_PERMISSIONS: keyof typeof ALL_CHAT_PERMISSIONS;}
interface TypeOf { DEFAULT_UPDATE_TYPES: typeof DEFAULT_UPDATE_TYPES; ALL_UPDATE_TYPES: typeof ALL_UPDATE_TYPES; ALL_CHAT_PERMISSIONS: typeof ALL_CHAT_PERMISSIONS;}type ValuesFor<T> = { [K in keyof T]: K extends keyof TypeOf ? Readonly<TypeOf[K]> : never;};
/** * A container for constants used in the Telegram Bot API. Currently holds all * available update types as well as all chat permissions. */export const API_CONSTANTS: ValuesFor<ApiConstants> = { DEFAULT_UPDATE_TYPES, ALL_UPDATE_TYPES, ALL_CHAT_PERMISSIONS,};Object.freeze(API_CONSTANTS);
grammy

Version Info

Tagged at
a month ago