Skip to content

Commit

Permalink
add Telegram Notification Bot Addon
Browse files Browse the repository at this point in the history
  • Loading branch information
PizzaG committed Dec 18, 2023
1 parent 14f9d41 commit c8a3f42
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Telegram_Bot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

#
# Copyright 2019-Present A-Team Digital Solutions
#
# A-Team Telegram Notification Bot Addon
#


# Telegram Bot Variables - **User Adaptable**
CHANNEL_ID='YOUR_CHANNEL_ID_HERE'
BOT_TOKEN='YOUR_BOT_TOKEN_HERE'


# if the first argument is "-h" for help.
# display the usage information
if [ "$1" == "-h" ]; then
echo "Usage: `basename $0` \"text message\""
exit 0
fi

# Warn if the first argument is empty.
if [ -z "$1" ]; then
echo "Add message text as the second argument"
exit 0
fi

# Warn if more than one argument is passed to the script.
if [ "$#" -ne 1 ]; then
echo "You can pass only one argument. For string with spaces, put it on quotes"
exit 0
fi

# send a POST request to Telegram's API
# The '-s' = "silent" mode
# redirect outputs to /dev/null
curl -s --data "text=$1" --data "chat_id=$CHANNEL_ID" 'https://api.telegram.org/bot'$BOT_TOKEN'/sendMessage' > /dev/null. Then follow instructions to create bot and get token to access the HTTP API.

0 comments on commit c8a3f42

Please sign in to comment.