forked from hackerlank/note
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtelegram
266 lines (149 loc) · 4.71 KB
/
telegram
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
telegram 机器人 BotFather
https://telegram.me/botfather
/newbot // 创建机器人
/token // 生成 token
/mybots // 机器人列表
// 编辑机器人
/setname // 更改机器人名字
/setdescription // 描述
/setabouttext // 机器人信息
/setuserpic // 个人资料图片
/setcommands // 更改机器人的命令列表 '/' 开头 不能超过32个字符 不区分大小写
/deletebot // 删除机器人
// 设置机器人
/setinline // 为您的机器人切换内联模式 ???
/setinlinegeo // 请求位置数据以提供基于位置的内联结果
/setjoingroups // 是否可加入组
/setprivacy // 是否接收群组消息
/newgame // 创建一个游戏
/listgames // 游戏列表
/editgame // 编辑游戏。
/deletegame // 删除现有游戏。
/mygames // 我的游戏
查看 所有 账号 状态
在线
账号信息
添加账号
登录账号
login - 登录 例: /login name otp
下载昨天返水
发送信息
回复一个 otp
账号退出登录
663898425:AAEXhfjJxMaprn4F3IjTYObQcJFAIk-Qg6U
我的 id 598910954
组 id -266500900
bot api
// 格式
https://api.telegram.org/bot<Token>/<Method Name>
获取信息
getUpdates (拉取)
webHook (推送)
setWebhook # 设置 webhook
url str # https网址 (支持的端口 443,80,88,8443)
[certificate] file # 证书
[max_connections] int # 最大连接数 1~100 默认40
[allowed_updates] arr|str # 指定接收那些内容的消息
deleteWebhook
getWebhookInfo
###tets###
leaveChat // 让机器人 离开一个 群 或 频道
chat_id int|str
getChat // 获取聊天对象的最新信息
chat_id int|str
getChatAdministrators // 获取 管理员列表
chat_id int|str
getChatMembersCount // 获取 成员个数
chat_id int|str
setChatStickerSet // 给群组设置标签 (要有权限)
chat_id int|str
sticker_set_name str
deleteChatStickerSet // 删除标签
chat_id int|str
@PollBot // 投票机器人
Available methods // 可用方法
getMe // 获取机器人信息 检验令牌
sendMessage // 发送信息
chat_id int|str
text str
[parse_mode] str 文本解析类型 markdown 或 html
[disable_web_page_preview] bool 是否禁止网站预览
[disable_notification] bool 是否是无声模式
[reply_to_message_id] int 回复消息唯一 id
[reply_markup] 回复标志
forwardMessage // 转发内容
chat_id int|str
from_chat_id int|str
[disable_notification] bool 无声
message_id int
https://upload.wikimedia.org/wikipedia/commons/thumb/6/62/Bundesstra%C3%9Fe_312_number.svg/1200px-Bundesstra%C3%9Fe_312_number.svg.png
Available types 可用类型
ForceReply // 强制回复
force_reply true 向用户显示回复界面
selective bool 是否根据 @ 或则 回复
// 内联模式
/setinline
InlineQuery
answerCallbackQuery // 内联键盘 发送的回调 成功为 true ???
callback_query_id
[text]
[show_alert]
[url]
[cache_time]
node 框架
const Telegraf = require('telegraf');
const { Markup, Telegram } = Telegraf;
Inline Keyboard inline的按钮不会造成客户端向机器人发送消息
util.sendMessage({
chat_id: -266500900,
text: '账号: `9zhounian` 掉线了 /otp',
parse_mode: 'Markdown',
reply_markup: JSON.stringify({
inline_keyboard: [[
{ text: '👍', callback_data: 'like' },
{ text: '👎', callback_data: 'dislike' }
]]
})
}, function(error, response, body){
console.log(body)
})
custom Reply Keyboard 自定义按钮
util.sendMessage({
chat_id: -266500900,
text: '账号: `9zhounian` 掉线了 /otp',
parse_mode: 'Markdown',
reply_markup: JSON.stringify({
keyboard: [[
{text: 'text1'},
{text: 'text2'}
]],
})
}, function(error, response, body){
console.log(body)
})
Reply Keyboard 用于快速回复
ForceReply 回复内容
util.sendMessage({
chat_id: -266500900,
text: '账号: `9zhounian` 掉线了 /otp',
parse_mode: 'Markdown',
reply_markup: JSON.stringify({
force_reply: true
})
}, function(error, response, body){
console.log(body)
})
// 浏览器使用时加上前面的域名
https://telegram.me/joinchat/EaEnSUPktgfoI-XPfMYtcQ
// 连接里面使用
tg://user?id=<user_id> 联系人信息
tg://join?invite= // 连接邀请
tg://addstickers?set=
tg://msg_url?
tg://confirmphone?
tg://socks?
tg://proxy?
tg://resolve/?domain=
# markdown
# Link
[like this](http://www.baidu.com)