-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
54 lines (34 loc) · 1.45 KB
/
index.js
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
const TelegramBot = require( `node-telegram-bot-api` )
const TOKEN = `275399831:AAHvjSOiGLxgXmff9wgdECdrZXfMtvnKURw`
const bot = new TelegramBot( TOKEN, { polling: true } )
bot.on( 'message', ( msg, match ) => {
console.log( 'msg', msg)
})
// const log = ( msg ) => console.log( msg )
// const logSuccess = ( data ) => console.log( `Success: `, data )
// const logError = ( err ) => console.log( `Error: `, err )
// const sendMessage = ( msg, match ) =>
// bot.sendMessage( msg.chat.id, match[ 1 ] )
// .then( logSuccess )
// .catch( logError )
// bot.on('message') eh a fn que pega qquer
// evento que chegue no bot
// bot.onText soh pegara textos que o bot receber
// const logSuccessEcho = ( msg, match ) => ( data ) => {
// console.log( `Success msg: `, msg )
// console.log( `Success match: `, match )
// console.log( `Success data: `, data )
// }
// const logErrorEcho = ( err ) => console.log( `Error: `, err )
// const sendEcho = ( msg, match ) =>
// bot.sendMessage( msg.chat.id, match[ 1 ] )
// .then( logSuccessEcho( msg, match ) )
// .catch( logErrorEcho )
// bot.onText( /\/echo (.*)/, sendEcho )
// const logSuccess = ( data ) => console.log( `Success: `, data )
// const logError = ( err ) => console.log( `Error: `, err )
// const receiveAsk = ( msg, match ) =>
// bot.sendMessage( msg.chat.id, match[ 1 ] )
// .then( logSuccess )
// .catch( logError )
// bot.onText( /\/ask (.*)/, sendMessage )