Skip to content

Commit

Permalink
Send from a date
Browse files Browse the repository at this point in the history
  • Loading branch information
yuuues committed Oct 24, 2022
1 parent 4d5bb10 commit e87fa2a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion base.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#CONFIG
DOCUMENT_ROOT=/var/www/html #Route to catch the files
CHAT_ID= #Channel or Group ID
INTERVAL= #Hours
CAPTION= #Text you will send
START_DATE= #Left empty to start from now or set a date in the format YYYY-MM-DD HH:MM:SS
INTERVAL= #Hours between posts

# Telegram API
API_ID=
Expand Down
6 changes: 5 additions & 1 deletion userbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ async def main():
async with app:
files = os.listdir(config.document_root)
files = [f for f in files if os.path.isfile(config.document_root + '/' + f)] # Filtering only the files.
schedule = datetime.datetime.now()

if config.start_date:
schedule = datetime.datetime.strptime(config.start_date, '%Y-%m-%d %H:%M:%S')
else:
schedule = datetime.datetime.now()

for x in files:
schedule = schedule + datetime.timedelta(hours=config.interval)
Expand Down
4 changes: 2 additions & 2 deletions userbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def get_env(key, needed=False, default=None):

api_id = get_env(key="API_ID", needed=True)
api_hash = get_env(key="API_HASH", needed=True)
string_session = get_env(key="STRING_SESSION")
document_root = get_env(key="DOCUMENT_ROOT")
chat_id = get_env(key="CHAT_ID")
interval = int(get_env(key="INTERVAL"))
caption = get_env(key="CAPTION")
caption = get_env(key="CAPTION")
start_date = get_env(key="START_DATE")

0 comments on commit e87fa2a

Please # to comment.