Guest User

Untitled

a guest
Sep 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import * as Telebot from 'telebot'
  2. import * as env from '../environment/environment-handler'
  3.  
  4. class BotService {
  5.  
  6. private static instance = new BotService();
  7.  
  8. private bot;
  9.  
  10. constructor() {
  11. if (!!BotService.instance) return BotService.instance;
  12.  
  13. // @ts-ignore
  14. this.bot = new Telebot(env.telegram.token);
  15. this.bot.on('text', this.textMessageHandler.bind(this));
  16. }
  17.  
  18. private textMessageHandler(msg): void {
  19. this.sendMessage(msg.chat.id, 'Submission complete');
  20. }
  21.  
  22. private sendMessage(chatId: string, msg: string): void {
  23. this.bot.sendMessage(chatId, msg);
  24. }
  25.  
  26. }
  27.  
  28. export default new BotService;
Add Comment
Please, Sign In to add comment