Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sw 2518 #85

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions src/green-api-v0.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const ApiClient = require('./core/network/client')
const whatsAppClient = require('@green-api/whatsapp-api-client')
const ApiUtils = require('./api-utils')


class GreenApiV0 extends ApiClient {

constructor(token, options, webhookResponse) {
Expand Down Expand Up @@ -201,6 +202,19 @@ class GreenApiV0 extends ApiClient {
return this.restAPI.message.sendMessage(chatId, null, textWithKeys)
}

sendLink (chatId, text, extra) {
Amele9 marked this conversation as resolved.
Show resolved Hide resolved
const textWithKeys = ApiUtils.keyEmulation(extra, text)
return this.restAPI.message.sendMessage(chatId, null, textWithKeys)
}

sendTemplateButtons(chatId, phone_number, message, footer = null, templateButtons) {
return this .restAPI.message.sendTemplateButtons(chatId, phone_number, message, footer = null, templateButtons)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переопределение значения footer

}

sendListMessage(chatId, message, buttonText, title, footer, sections) {
return this.restAPI.message.sendListMessage(chatId, message, buttonText, title, footer, sections)
}

forwardMessage (chatId, fromChatId, messageId, extra) {
return this.callApi('forwardMessage', {
chat_id: chatId,
Expand Down Expand Up @@ -238,7 +252,7 @@ class GreenApiV0 extends ApiClient {
}

sendContact (chatId, phoneNumber, firstName, extra) {
return this.restAPI.file.sendContact(chatId, null, {
return this.restAPI.messages.sendContact(chatId, null, {
phoneContact: phoneNumber,
firstName: firstName,
})
Expand All @@ -252,8 +266,16 @@ class GreenApiV0 extends ApiClient {
return this.callApi('sendDice', { chat_id: chatId, ...extra })
}

sendDocument (chatId, document, extra) {
return this.restAPI.file.sendFileByUrl(chatId, null, document, 'document')
sendFileByUrl (chatId,urlFile, file_name, caption = '',quotedMessageId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Описание картинки должно быть нулевым. После проверка на нулевое значение. Если null то не добавляем в postData.

return this.restAPI.file.sendFileByUrl(chatId,urlFile, file_name, caption = '',quotedMessageId)
Amele9 marked this conversation as resolved.
Show resolved Hide resolved
}

sendFileByUpload (document) {
andreyMalyshkin marked this conversation as resolved.
Show resolved Hide resolved
return this.restAPI.file.sendFileByUpload(document)
}

uploadFile(filePath) {
this.restAPI.file.uploadFile(filePath)
}

andreyMalyshkin marked this conversation as resolved.
Show resolved Hide resolved
sendAudio (chatId, audio, extra) {
Expand Down Expand Up @@ -288,8 +310,12 @@ class GreenApiV0 extends ApiClient {
return this.callApi('sendMediaGroup', { chat_id: chatId, media, ...extra })
}

sendPoll (chatId, question, options, extra) {
return this.callApi('sendPoll', { chat_id: chatId, type: 'regular', question, options, ...extra })
sendPoll (chatId, message, options, multipleAnswers, quotedMessageId) {
return this.restAPI.message.sendPoll(chatId, message, options, multipleAnswers , quotedMessageId)
Amele9 marked this conversation as resolved.
Show resolved Hide resolved
}

sendButtons (chatId, message, footer, buttons){
return this.restAPI.message.sendButtons(chatId, message, footer, buttons)
}

sendQuiz (chatId, question, options, extra) {
Expand Down