A simple telegram bot that monitors changes in directories
Project description
telefilebot
Sometimes you have code that runs a long time and you do not want to continuously check if it has finished. If that code writes a file to the disk at the end, maybe you just want a text message when that file is created or modified?
telefilebot
allows you to do this with as a simple background listener. All
you need is an input YAML file and you can monitor multiple directories for
various new files being created.
Installation
pip install telefilebot
Usage
Say you have two directories you want to monitor. In one of them you want to look for text files (files ending with a .txt extension) and the other you only want to scan the top two level directories.
First you need to create a telegram bot and attach it to some group where it can message you.
Now, create a YAML file that looks like this:
name: "file_monitor"
chat_id: "-XXXXXXXX"
token: "XXXXXXX"
logging:
level: "INFO"
directories:
"~/my_dir1":
extensions:
- .txt
"~/my_dir2":
recursion_limit: 0
wait_time: 1
What do these things mean? The name just names the bot. The chat_id
and
token
are from you group and bot you created. logging
sets the verbosity of
the printout in the terminal. For each directory you want to monitor, create an
entry with the directory path. If you want to monitor only certain file
extensions, list them under the director. If you only want to recurse down to a
certain level in the file structure, enter a recursion limit (here zero
means
only the path entered and no sub-folders will be scanned).
Finally, the wait_time
argument specifies in minutes how long to wait between
checks of the file system.
Now simply fire up a tmux session (or however you want to the bot to run in the background) and enter
telefilebot --file=input.yml
and you are done! Your bot will let you know when new files are added or modified.
- Free software: GNU General Public License v3
- Documentation: https://telefilebot.readthedocs.io.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file telefilebot-0.1.1.tar.gz
.
File metadata
- Download URL: telefilebot-0.1.1.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 952025cdc65bde3175e0f1d9532c550d621238da9dda38930845d100a9c28719 |
|
MD5 | 68a73089f64d7707c21a9a483ececa15 |
|
BLAKE2b-256 | a29017e6397fc4f223e39d6fdb51d00bdf9705de64704b72316adafb472106ff |