Toggle navigation
Toggle navigation
This project
Loading...
Sign in
kykint
/
TELEGRAMBOT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
kykint
2019-05-30 22:27:21 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3c355795f3d2abde2dd5d0aec6e65be1f5207c3a
3c355795
1 parent
122d46c1
Detect normal message using regex
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
app.js
app.js
View file @
3c35579
...
...
@@ -31,15 +31,15 @@ bot.onText(/\/echo (.+)/, (msg, match) => {
bot
.
sendMessage
(
chatId
,
resp
);
});
//
Listen for any kind of message. Translate if it's not a command.
bot
.
on
(
'message'
,
(
msg
)
=>
{
//
[Any normal message which is not a command (not starting with '/')]
bot
.
on
Text
(
/
(?!\/)(
.+
)
/
,
(
msg
,
match
)
=>
{
const
chatId
=
msg
.
chat
.
id
;
const
chatType
=
msg
.
chat
.
type
;
const
received_msg
=
m
sg
.
text
;
const
received_msg
=
m
atch
[
1
]
;
// Ignore if
input is a command or
we are not on a private chat,
// Ignore if we are not on a private chat,
// since direct translation is to be used only on private chats.
if
(
received_msg
[
0
]
==
'/'
||
chatType
!=
'private'
)
{
if
(
chatType
!=
'private'
)
{
return
;
}
...
...
Please
register
or
login
to post a comment