Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wfjsw committed Sep 10, 2018
1 parent a7965d7 commit ce42dc1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
38 changes: 26 additions & 12 deletions bot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,23 @@ class Bot extends lib.TdClientActor {
this.ready = false
this._inited_chat = new Set()
if (bot_token) {
this.on('__updateAuthorizationState', (update) => {
this.on('__updateAuthorizationState', async (update) => {
switch (update.authorization_state['@type']) {
case 'authorizationStateWaitPhoneNumber':
await this.run('setOption', {
name: 'ignore_inline_thumbnails',
value: {
'@type': 'optionValueBoolean',
value: true
}
})
await this.run('setOption', {
name: 'disable_top_chats',
value: {
'@type': 'optionValueBoolean',
value: true
}
})
return this.run('checkAuthenticationBotToken', {
token: bot_token
})
Expand Down Expand Up @@ -129,11 +143,11 @@ class Bot extends lib.TdClientActor {
}
if (options.caption)
media.caption = await this._generateFormattedText(options.caption, options.parse_mode)
if (options.duration)
if (options.duration)
media.duration = options.duration
if (options.title)
media.title = options.title
if (options.performer)
if (options.performer)
media.performer = options.performer
return this._sendMessage(chat_id, media, options)
}
Expand Down Expand Up @@ -206,7 +220,7 @@ class Bot extends lib.TdClientActor {
let _md = {
'@type': 'inputMessagePhoto',
photo: await this._prepareUploadFile(md.media)
}
}
if (md.caption)
_md.caption = await this._generateFormattedText(md.caption, md.parse_mode)
_medias.push(_md)
Expand Down Expand Up @@ -947,13 +961,13 @@ class Bot extends lib.TdClientActor {
if (!this.ready) throw new Error('Not ready.')
let media = {
'@type': 'inputMessageInvoice',
title,
title,
description,
payload,
provider_token,
start_parameter,
invoice: {
currency,
currency,
price_parts: [],
need_name: !!options.need_name,
need_phone_number: !!options.need_phone_number,
Expand All @@ -964,7 +978,7 @@ class Bot extends lib.TdClientActor {
is_flexible: !!options.is_flexible
}
}
for (let pp of prices) {
for (let pp of prices) {
media.invoice.price_parts.push(pp)
}
if (provider_token.match(/:TEST:/)) {
Expand All @@ -978,7 +992,7 @@ class Bot extends lib.TdClientActor {
media.photo_width = options.photo_width
if (options.photo_height)
media.photo_height = options.photo_height
if (options.provider_data)
if (options.provider_data)
media.provider_data = options.provider_data
return this._sendMessage(chat_id, media, options)
}
Expand Down Expand Up @@ -1023,7 +1037,7 @@ class Bot extends lib.TdClientActor {
else throw ret
}



// Helpers

Expand Down Expand Up @@ -1261,7 +1275,7 @@ class Bot extends lib.TdClientActor {
evt.inline_message_id = update.inline_message_id
}
switch (update.payload['@type']) {
case 'callbackQueryPayloadData':
case 'callbackQueryPayloadData':
evt.data = Buffer.from(update.payload.data, 'base64').toString('utf8')
break
case 'callbackQueryPayloadGame':
Expand All @@ -1281,7 +1295,7 @@ class Bot extends lib.TdClientActor {
}
if (update.user_location) {
evt.location = await this.conversion.buildLocation(update.user_location)
}
}
return this.emit('inline_query', evt)
}

Expand All @@ -1295,7 +1309,7 @@ class Bot extends lib.TdClientActor {
}
if (update.user_location) {
evt.location = await this.conversion.buildLocation(update.user_location)
}
}
return this.emit('inline_query', evt)
}

Expand Down
2 changes: 1 addition & 1 deletion td
Submodule td updated 400 files
16 changes: 15 additions & 1 deletion td_client_actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,23 @@ class TdClientActor extends EventEmitter {
}
this._tdlib_param = tdlib_param
this._encryption_key = 'database_encryption_key' in options ? options.database_encryption_key : 'password'
this.on('__updateAuthorizationState', (update) => {
this.on('__updateAuthorizationState', async (update) => {
switch (update.authorization_state['@type']) {
case 'authorizationStateWaitTdlibParameters':
await this.run('setOption', {
name: 'ignore_inline_thumbnails',
value: {
'@type': 'optionValueBoolean',
value: true
}
})
await this.run('setOption', {
name: 'disable_top_chats',
value: {
'@type': 'optionValueBoolean',
value: true
}
})
return this.run('setTdlibParameters', {
parameters: tdlib_param
})
Expand Down

0 comments on commit ce42dc1

Please sign in to comment.