FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/archive/code/index.js at main · iu5git/JavaScript · GitHub
iu5git
/
JavaScript
Public
Notifications
You must be signed in to change notification settings
Fork
21
Star
52
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
archive
/
code
/
index.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
29 lines (22 loc) · 965 Bytes
Breadcrumbs
JavaScript
/
archive
/
code
/
index.js
Copy path
File metadata and controls
executable file
·
29 lines (22 loc) · 965 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
const
TelegramBot
=
require
(
'node-telegram-bot-api'
)
;
// replace the value below with the Telegram token you receive from
@BotFather
const
token
=
'1015753614:AAHY6gqC8JQ5mWbDVRNO_xWmVIatER8n9-I'
;
// Create a bot that uses 'polling' to fetch new updates
const
bot
=
new
TelegramBot
(
token
,
{
polling
:
true
}
)
;
// Matches "/echo [whatever]"
bot
.
onText
(
/
\/
e
c
h
o
(
.
+
)
/
,
(
msg
,
match
)
=>
{
// 'msg' is the received Message from Telegram
// 'match' is the result of executing the regexp above on the text content
// of the message
const
chatId
=
msg
.
chat
.
id
;
const
resp
=
match
[
1
]
;
// the captured "whatever"
// send back the matched "whatever" to the chat
bot
.
sendMessage
(
chatId
,
resp
)
;
}
)
;
// Listen for any kind of message. There are different kinds of
// messages.
bot
.
on
(
'message'
,
(
msg
)
=>
{
const
chatId
=
msg
.
chat
.
id
;
// send a message to the chat acknowledging receipt of their message
bot
.
sendMessage
(
chatId
,
'Received your message'
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL