Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
hubot-telegram
Advanced tools
Readme
Hubot adapter for interfacting with the Telegram Bot API
First of read the docs on how to create a new Telegram Bot. Once you have a bot created, follow these steps:
npm install --save hubot-telegram
bin/hubot -a telegram
This adapter uses the following environment variables:
TELEGRAM_TOKEN (required)
The token that the BotFather gives you
TELEGRAM_INTERVAL (optional)
You can specify the interval (in milliseconds) in which the adapter will poll Telegram for updates. This option only applies if you are not using a webhook.
TELEGRAM_WEBHOOK (optional)
You can specify a webhook URL. The adapter will register TELEGRAM_WEBHOOK/TELEGRAM_TOKEN with Telegram and listen there.
The adapter will enhance the Response object with some custom methods with the same signature of the APIs. For example, sending an image:
module.exports = function (robot) {
robot.hear(/send totoro/i, res => {
const image = fs.createReadStream(__dirname + '/image.png')
// https://core.telegram.org/bots/api#sendphoto
res.sendPhoto(res.envelope.room, image, {
caption: 'Totoro!'
})
})
}
Note: An example script of how to use this is located in the example/
folder
The list of methods exposed through a middleware to the response object is:
If you want to supplement your message delivery with extra features such as markdown syntax or keyboard replies, you can specify these parameters on the options
of sendMessage:
robot.respond(/(.*)/i, res => {
res.sendMessage(
res.envelope.room,
'Select the option from the keyboard specified.',
{
reply_markup: {
keyboard: [['Start', 'Stop']]
}
}
)
})
inlineQuery
are a way to reply without a conversation to the bot. That's why they don't really fit into the normal hear/respond flow of Hubot.
To support inlineQuery
you can listen to event on the telegram
object exposed by the robot
object.
module.exports = function (robot) {
robot.telegram.on('inline_query', async inlineQuery => {
// Initially there is always a query with empty string
// Usually is to provide suggestions
if (inlineQuery.query) {
const searches = await google.search(inlineQuery.query, 50) // Max 50 results for inlineQuery
const results = searches.map(result => ({
type: 'photo',
id: result.id,
thumb_url: result['thumbnail'],
photo_url: result['url']
}))
robot.telegram.answerInlineQuery(inlineQuery.id, results)
}
})
}
FAQs
Hubot adapter for Telegram
The npm package hubot-telegram receives a total of 15 weekly downloads. As such, hubot-telegram popularity was classified as not popular.
We found that hubot-telegram demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.