nodegin / tglib

TDLib (Telegram Database library) bindings for Node.js
114 stars 16 forks source link

botcommands example doesnt work :( #36

Closed akhokhlushin closed 6 years ago

akhokhlushin commented 6 years ago

lepres@akho ~/telegram-javascript $ node botcommands.js (node:3038) Warning: N-API is an experimental feature and could change at any time. Authorizing bot (671139129:AAETpkzzIRTvUDDN3UXUpx8kCdJB8PcOEEA) (node:3038) UnhandledPromiseRejectionWarning: Error: No text defined for method "sendTextMessage". at TG.sendTextMessage (/home/lepres/node_modules/tglib/TG.js:24:13) at client.registerCallback (/home/lepres/telegram-javascript/botcommands.js:26:27) at Client.handleUpdate (/home/lepres/node_modules/tglib/Client.js:263:37) at Client.loop (/home/lepres/node_modules/tglib/Client.js:124:22) at (node:3038) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3) (node:3038) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:3038) UnhandledPromiseRejectionWarning: Error: No text defined for method "sendTextMessage". at TG.sendTextMessage (/home/lepres/node_modules/tglib/TG.js:24:13) at client.registerCallback (/home/lepres/telegram-javascript/botcommands.js:24:27) at Client.handleUpdate (/home/lepres/node_modules/tglib/Client.js:263:37) at Client.loop (/home/lepres/node_modules/tglib/Client.js:124:22) at (node:3038) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)

nodegin commented 6 years ago

May I have your sendTextMessage code?

The correct way to send text messages from v2.0:

const { TextStruct } = require('tglib/structs')

await client.tg.sendTextMessage({
  '$text': new TextStruct('`Hello` world!', 'textParseModeMarkdown'),
  'chat_id': 123456789,
  'disable_notification': true,
  'clear_draft': false,
})
nodegin commented 6 years ago

Ah, sorry I forgot to update the example..