
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
TelegramAlerts is a Ruby gem that allows you to receive notifications about exceptions and alerts in your Ruby applications through Telegram. The notifications include information such as the exception class, message, backtrace, environment, and time of occurrence.
Install the gem and add to the application's Gemfile by executing:
$ bundle add telegram_alerts
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install telegram_alerts
In order to use TelegramAlerts, you need to create a subclass of TelegramAlerts::ChatMixin and set the chat key.
The exception
function returns a message in HTML format. The message includes:
Each piece of information is separated by newlines and formatted with either bold or italic text to distinguish different elements of the message.
The message
function is responsible for sending an message to the specified Telegram channel. The message includes information about the severity of the issue, the date and time, and a descriptive message.
The available severity levels in the TelegramAlert gem are:
Here's an example of how to use TelegramAlerts in a Ruby application:
require 'telegram_alerts'
TelegramAlerts.chats_settings.merge!({
monitor: {
bot_token: 'BOT_TOKEN',
chat_id: 'MONITOR_CHAT_ID',
host_name: `hostname`.strip,
project_name: 'AwesomeProject'
},
logs: {
bot_token: 'BOT_TOKEN',
chat_id: 'LOGS_CHAT_ID',
host_name: `hostname`.strip,
project_name: 'AwesomeProject'
}
})
module AwesomeProjectAlertsChats
class MonitorChat < TelegramAlerts::ChatMixin
def self.chat
:monitor
end
end
class LogsChat < TelegramAlerts::ChatMixin
def self.chat
:logs
end
end
end
Then, In your application code, you can use the log_exception
method to log an exception and receive a notification to the Telegram chat or group:
begin
# Some code that raises an exception
rescue => e
AwesomeProjectAlertsChats::MonitorChat.exception(e, 'FATAL', 'A fatal error has occurred.')
end
You can also use the message
method to send an notification to Telegram:
AwesomeProjectAlertsChats::LogsChat.message('User created', 'INFO')
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/telegram_alerts.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that telegram_alerts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.