telegram-webhook-js
Advanced tools
Comparing version 1.0.5 to 1.0.51
33
main.js
@@ -220,3 +220,3 @@ // telegram-bot.js | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ callback_query_id: callbackQuery.id}), | ||
body: JSON.stringify({ callback_query_id: callbackQuery.id }), | ||
}); | ||
@@ -261,10 +261,10 @@ } | ||
const fileId = photoArray[photoArray.length - 1].file_id; | ||
// Get file path | ||
const fileInfo = await this.getFile(fileId); | ||
const filePath = fileInfo.file_path; | ||
// Construct the download URL | ||
const fileUrl = `https://api.telegram.org/file/bot${this.token}/${filePath}`; | ||
return fileUrl; // Return the URL to download the image | ||
@@ -276,3 +276,3 @@ } else { | ||
} | ||
async getFile(fileId) { | ||
@@ -287,3 +287,24 @@ try { | ||
} | ||
async getFullNameById(userId) { | ||
try { | ||
// Make a request to get chat information | ||
const response = await fetch(`${this.apiUrl}getChat?chat_id=${userId}`); | ||
const data = await response.json(); | ||
// Check if the data contains user information | ||
if (data.ok && data.result) { | ||
const user = data.result; | ||
// Construct and return the full name (first + last name) | ||
const fullName = `${user.first_name} ${user.last_name || ''}`.trim(); | ||
return fullName; | ||
} else { | ||
console.error('Error: Unable to fetch user details.'); | ||
return null; | ||
} | ||
} catch (error) { | ||
console.error('Error fetching user info:', error); | ||
return null; | ||
} | ||
} | ||
} | ||
@@ -290,0 +311,0 @@ |
{ | ||
"name": "telegram-webhook-js", | ||
"version": "1.0.5", | ||
"version": "1.0.51", | ||
"main": "main.js", | ||
@@ -5,0 +5,0 @@ "type": "commonjs", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17827
273
13