-
Notifications
You must be signed in to change notification settings - Fork 24
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
send photo instead of text #30
Comments
You can send your messages with photo as text messages for testing purposes. I have a simple solution for Telegraf Bot Framework. const Telegraf = require('telegraf')
const TelegrafContext = require('telegraf/context')
class MyContext extends TelegrafContext {
replyWithPhoto (photo, ...extra) {
const { caption, ...rest } = extra[0]
this.assert(this.chat, 'reply')
const text = `[${photo}]\n${caption}`
return this.telegram.sendMessage(this.chat.id, text, rest)
}
}
const bot = new Telegraf("bot_token", {
telegram: {
apiRoot: server.ApiURL,
},
contextType: MyContext,
}) |
I saw that this package use express, so it will be possible to handle multipart requests but I'm not sure how to code, someone want to discuss some improvements to this library? |
Hello @b3nab . Funny enough, I was just looking at implementing this feature into the library as it is required by me as well. Need to send photos/files rather than text. |
Is this repository still being monitored ? |
Are pull requests still welcome? |
Yup, still monitored but not in development. PRs welcome! |
This is just for telegraf framework right? Not node-telegram-api |
Alright. Cool! |
What is photo in this case? |
@aveeday Please kindly look at my questions |
This patch is just for telegraf. It is not necessary to run telegram server for testing locally. I think the best practices are just require bot in test file and call handle update method. |
I just got to know that you built another test library called telegram-test. Does that have the functionality of client being able to send images by any chance? |
Thanks for the reply @aveeday . This library starts a server locally, are you saying that is not neccessary for testing locally? Sorry for the questions. Kind of new to this. Also, can you pls point me to a sample test file/project you have written in the past? Thanks |
Telegram bot can send messages in two ways:
All this external communications can be mocked and bot answers can be checked in tests. I created a simple testing example to show the proof of this concept. This implementation can be easily extended for your specific needs and rewritten to any language, framework and libs you like. You can integrate this bot with Express or any other http framework/infrastructure with |
@jehy After changes are being made to this library which changes some APIs, will a new version be released? |
@tundeOlagunju yup, everything will happen according to semantic versioning model. |
Is there a way to send a photo instead of text
The text was updated successfully, but these errors were encountered: