Compare commits

...

2 Commits

Author SHA1 Message Date
Profitroll 91a65d9b49 Changed requirements-check procedure 2022-08-09 12:31:11 +02:00
Profitroll a29fd26046 Added start scripts 2022-08-09 12:30:36 +02:00
6 changed files with 52 additions and 3 deletions

View File

@ -4,6 +4,12 @@ This bot is used for one and only task - post pictures from my personal archive.
## Installation
To make this bot run at first you need to have a Python interpreter and git. Google is your friend finding it. You can also ignore git and simply download source code, should also work fine. After that you're ready to go.
> In this README I assume that you're using default python in your
> system and your system's PATH contains it. If your default python
> is `python3` or for example `/home/user/.local/bin/python3.9` - use it instead.
> If it's non-standart executable path - you should also change
> it in scripts you will use (`loop.sh`, `loop.bat`, `start.sh` and `start.bat`).
1. Download the bot.
1. `git clone https://git.end-play.xyz/profitroll/TelegramSender.git` (if you want to use git)
2. `cd ./TelegramSender`
@ -28,7 +34,9 @@ To make this bot run at first you need to have a Python interpreter and git. Goo
Of course bot cannot post something from nothing. Configure your `config.json` what media types bot should post (`"posting", "extensions"`), when to post them (`"posting", "time"`) and also where to find them (`"locations"`). You can also move them when sent by setting `"posting", "move_sent"` to `true`.
6. Good to go, run it!
`python ./main.py`
`python ./main.py`
Or you can also use `.\start.bat` on Windows and `bash ./start.sh` on Linux.
Additionally there are `loop.sh` and `loop.bat` available if you want your bot to start again after being stopped or after using `/reboot` command.
## Command line arguments
Of course bot also has them. You can perform some actions with them.

12
loop.bat Normal file
View File

@ -0,0 +1,12 @@
@echo off
REM You can cd to your directory here, if you want
REM cd C:\Users\user\TelegramPoster
:start
python main.py
echo To completely stop TelegramPoster now, please press Ctrl+C during the countdown!
echo Restarting in 5 seconds...
Timeout /t 5
echo TelegramPoster has started!
goto start

17
loop.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# You can cd to your directory here, if you want
# cd /home/user/TelegramPoster
while true
do
python main.py
echo "To completely stop TelegramPoster now, please press Ctrl+C during the countdown!"
echo "Restarting in:"
for i in 5 4 3 2 1
do
echo "$i..."
sleep 1
done
echo "TelegramPoster has started!"
done

View File

@ -6,7 +6,6 @@ import sys
from threading import Thread
import time
import traceback
import schedule
from modules.logging import logWrite
from modules.utils import configGet, jsonLoad, jsonSave
@ -57,10 +56,11 @@ if "--norun" in sys.argv:
sys.exit()
try:
import schedule # type: ignore
from pyrogram import Client, filters, idle # type: ignore
from pyrogram.types import ChatPermissions, ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton, BotCommand, BotCommandScopeChat # type: ignore
except ModuleNotFoundError:
print(f"Module pyrogram is not installed. Run 'pip3 install -r requirements.txt' and restart the program.", flush=True)
print(f"Required modules are not installed. Run 'pip3 install -r requirements.txt' and restart the program.", flush=True)
sys.exit()
app = Client("duptsiaposter", bot_token=configGet("bot_token", "bot"), api_id=configGet("api_id", "bot"), api_hash=configGet("api_hash", "bot"))

6
start.bat Normal file
View File

@ -0,0 +1,6 @@
@echo off
REM You can cd to your directory here, if you want
REM cd C:\Users\user\TelegramPoster
python main.py

6
start.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
# You can cd to your directory here, if you want
# cd /home/user/TelegramPoster
python main.py