Git Product home page Git Product logo

ntfy-sh-listener's Introduction

NTFY Listener ๐Ÿš€

docker-image

ntfy.sh to Telegram forwarder

Forward ntfy.sh Push Messages ๐Ÿš€ to Telegram by using telegram bot and websocket ๐Ÿ›ธ

using ntfy.sh websocket to Listen the ntfy.sh topic Push Notifications via websocket Connection and Forward it to Telegram via bot.

API

Ntfy.sh websocket API - https://docs.ntfy.sh/subscribe/api/?h=websoc#websockets

Setup

  • Download or Clone the Repo via git
git clone https://github.com/sanwebinfo/ntfy-sh-listener
cd ntfy-sh-listener

## install packages
pip install -r requirements.txt
touch .env
  • Env File .env
  • Replace ntfy.sh/ with your push server URL
NTFY_WS = "ntfy.sh/"
NTFY_ACCESS_CONTROL = "<ACCESS TOKEN>" # This field is optional, only there in case you need to use some authentication. You will need to generate an access token as explained here: https://docs.ntfy.sh/publish/#access-tokens
NTFY_TOPIC ="<YOUR TOPIC>"
TELEGRAM_BOT = "https://api.telegram.org/bot<YOUR BOT API TOKEN>/sendMessage"
TELEGRAM_ID = "<CHAT ID>"
  • Test
python3 ntfy.py

Docker ๐Ÿฌ

Keep Running the Python Script in Docker

  • Update the .dockerfile before build - Replace example ENV with yours
FROM python:3.8.10
ENV PYTHONUNBUFFERED 1
RUN pip install --upgrade pip
RUN pip3 install requests python-dotenv websocket-client
ENV NTFY_WS = "ntfy.sh/"
ENV NTFY_TOPIC ="<YOUR TOPIC>"
ENV NTFY_ACCESS_CONTROL = "<ACCESS TOKEN>"
ENV TELEGRAM_BOT = "https://api.telegram.org/bot<YOUR BOT API TOKEN>/sendMessage"
ENV TELEGRAM_ID = "<CHAT ID>"
COPY ntfy.py /usr/bin
CMD ["python3", "/usr/bin/ntfy.py"]
## Build image
docker build . -t="ntfy-sh-listener"

## List the image
docker image ls

## Create and Test Container
docker run -d --name ntfysh ntfy-sh-listener
docker container ps
docker stop (containerID)

## Run the container forever
docker run -d --restart=always --name ntfysh ntfy-sh-listener

## List Hidden container if error exists
docker ps -a

## other commands
docker logs (containerID)
docker stop (containerID)
docker rm (containerid)
docker docker rmi (imageid)
docker image prune
docker builder prune --all -f
docker system prune --all
docker rm $(docker ps -all -q)
docker rmi $(docker image ls -q)

Inspiration

Pushtify (Gotify to Pushover forwarder) - https://github.com/sebw/pushtify

LICENSE

MIT

ntfy-sh-listener's People

Contributors

thenaubit avatar mskian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.