Closed vitalyavolyn closed 6 years ago
Right now, if command module is in another file, sending messages works like this
// index.ts import module from './modules/hello' const bot = new Bot({...}) export default bot bot.get(module.regex, module.callback) // modules/hello.ts import bot from '../' export const regex = /Hi/i export function callback (msg, exec) { bot.send('Hi', msg.peer_id) }
There's a way to make it shorter - pass a reply fn that sends text to peer_id of the message
reply
// index.ts import module from './modules/hello' const bot = new Bot({...}) bot.get(module.regex, module.callback) // modules/hello.ts export const regex = /Hi/i export function callback (msg, exec, reply) { reply('Hi') }
Right now, if command module is in another file, sending messages works like this
There's a way to make it shorter - pass a
reply
fn that sends text to peer_id of the message