All Projects → forons → telegram-log

forons / telegram-log

Licence: Apache-2.0 license
Send a Telegram message when your scripts fire an exception or when they finish their execution.

Programming Languages

java
68154 projects - #9 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to telegram-log

LilSholex
A project containing web apps and Telegram API bots.
Stars: ✭ 32 (+100%)
Mutual labels:  telegram-api, telegram-bot-api
Java Telegram Bot Api
Telegram Bot API for Java
Stars: ✭ 819 (+5018.75%)
Mutual labels:  telegram-api, telegram-bot-api
TelegramBots-Python
TelegramBots written in Python
Stars: ✭ 15 (-6.25%)
Mutual labels:  telegram-api, telegram-bot-api
telegram
📚 Golang bindings for Telegram API
Stars: ✭ 15 (-6.25%)
Mutual labels:  telegram-api, telegram-bot-api
herald
Log annotation for logging frameworks
Stars: ✭ 71 (+343.75%)
Mutual labels:  log4j, logger
telegram client
library for help you make userbot or bot telegram and support tdlib telegram database and only support nodejs dart and google-apps-script
Stars: ✭ 38 (+137.5%)
Mutual labels:  telegram-api, telegram-bot-api
Informer
A Telegram Mass Surveillance Bot in Python
Stars: ✭ 745 (+4556.25%)
Mutual labels:  telegram-api, telegram-bot-api
node-tdlib
TDLib Binding with Telegram Bot API Reimplemention for Node.js
Stars: ✭ 35 (+118.75%)
Mutual labels:  telegram-api, telegram-bot-api
Python Telegram
Python client for the Telegram's tdlib
Stars: ✭ 246 (+1437.5%)
Mutual labels:  telegram-api, telegram-bot-api
Lulzbot Telegram Bot
Moved to https://gitlab.com/bhavyanshu/lulzbot-telegram-bot
Stars: ✭ 18 (+12.5%)
Mutual labels:  telegram-api, telegram-bot-api
grouphelperbot
A Telegram Bot made to help group admins, with Italian/English support.
Stars: ✭ 26 (+62.5%)
Mutual labels:  telegram-api, telegram-bot-api
loggers
Abstract logging for Golang projects. A kind of log4go in the spirit of log4j
Stars: ✭ 17 (+6.25%)
Mutual labels:  log4j, logger
tdlight-telegram-bot-api
The TDLight Telegram Bot API is an actively enhanced fork of the original Bot API, featuring experimental user support, proxies, unlimited files size, and more.
Stars: ✭ 71 (+343.75%)
Mutual labels:  telegram-api, telegram-bot-api
echotron
An elegant and concurrent library for Telegram bots in Go.
Stars: ✭ 95 (+493.75%)
Mutual labels:  telegram-api, telegram-bot-api
Bybit-Auto-Trading-Bot-Ordes-placed-via-TradingView-Webhook
Python based Trading Bot that uses TradingView.com webhook JSON alerts to place orders(buy/sell/close/manage positions/TP/SL/TS etc.) on Bybit.com. Hire me directly here https://www.freelancer.com/u/Beannsofts for any assistance
Stars: ✭ 235 (+1368.75%)
Mutual labels:  telegram-api, telegram-bot-api
Telegram
Telegram Bot API Wrapper for Scala
Stars: ✭ 310 (+1837.5%)
Mutual labels:  telegram-api, telegram-bot-api
tdlight-java
Complete Bot and Userbot Telegram library based on TDLib
Stars: ✭ 128 (+700%)
Mutual labels:  telegram-api, telegram-bot-api
JavaTelegramBot-API
Java Telegram Bot API
Stars: ✭ 34 (+112.5%)
Mutual labels:  telegram-api, telegram-bot-api
Mypackbot
🤖 Your own unlimited pack of Telegram-stickers
Stars: ✭ 18 (+12.5%)
Mutual labels:  telegram-api, telegram-bot-api
liquibase-slf4j
Liquibase SLF4J Logger.
Stars: ✭ 42 (+162.5%)
Mutual labels:  log4j, logger

Telegram-Log – Send message to a Telegram Bot or use it as a logger!

Telegram-Log is a simple way to interact from multiple programming languages to a Telegram Bot.

It is released under a Apache License 2.0.

Before everything: Create the bot

Following what is written here, the first step to create a bot is to start a new conversation with BotFather. With it, create a new bot with /newbot, then assign it a name and a unique username following the instructions.

The BotFather will answer with a TOKEN, which will be needed to later use the Telegram-Log application.

Then, start a conversation with the new created bot, searching it through the global search.

Now, write /start and start a conversation.

Go to https://api.telegram.org/bot<TOKEN>/getUpdates (replacing <TOKEN> with the token of your bot) and you will receive a JSON that contains something like:

..."chat":{"id":123456789,"first_name":"your_name","username":"your_username",type":"private"}...

You also need the chat id in order to use the Telegram-Log application.

Now you are ready to go to the next step!

Quickstart

Java

To use the application you need to:

git clone https://github.com/forons/telegram-log.git
mvn clean install

Then, you will be able to import this project in any of your projects simply by adding in the pom.xml:

	<dependency>
		<groupId>it.forons.utils</groupId>
		<artifactId>telegram</artifactId>
		<version>1.0-SNAPSHOT</version>
	</dependency>
Usage 1: Send message

As explained in src/main/java/it/forons/utils/telegram/TelegramSender.java there two ways to send messages to a Telegram Bot:

TelegramBot bot = new TelegramBot(TOKEN, CHAT_ID);
int responseCode = bot.sendMessage("Option 1: build the class and send the message.");

or

TelegramBot.sendMessage(TOKEN, CHAT_ID, "Option 2: static method.");
Usage 2: log4j Appender

To use Telegram-Log as a log4j appender it is just needed to add the maven dependency and to set the following lines into the log4j.properties file:

# Root logger option
log4j.rootLogger=INFO, telegram

# Direct log messages to the telegram bot
log4j.appender.telegram=it.forons.utils.telegram.appender.TelegramAppender
log4j.appender.telegram.TOKEN=<TOKEN>
log4j.appender.telegram.CHAT_ID=<CHAT_ID>
log4j.appender.telegram.layout=org.apache.log4j.PatternLayout
log4j.appender.telegram.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

Python

Just configure

TELEGRAM_TOKEN = ''
TELEGRAM_CHAT_ID = ''

with your TOKENID and CHATID, then use it as a simple Python logger:

logger = logging.getLogger('trymeApp')
	logger.setLevel(logging.WARNING)

	handler = RequestsHandler()
	formatter = LogstashFormatter()
	handler.setFormatter(formatter)
	logger.addHandler(handler)

	logger.setLevel(logging.WARNING)

	logger.error('We have a problem')

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

Marco De Nadai and Paolo Sottovia for the inspiration


Thank you to everyone who will report bugs, propose extra features, and suggest fixes.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].