Added a dry run option
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
16
main.py
16
main.py
@@ -2,15 +2,21 @@ import os
|
||||
from dotenv import load_dotenv
|
||||
from telethon.sync import TelegramClient
|
||||
import markovify
|
||||
from argparse import ArgumentParser
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("-d", "--dry", action='store_true', help="Run without sending a message")
|
||||
args = parser.parse_args()
|
||||
|
||||
load_dotenv()
|
||||
|
||||
api_id = os.getenv('API_ID')
|
||||
api_hash = os.getenv('API_HASH')
|
||||
entity = os.getenv('ENTITY')
|
||||
dry_run = args.dry
|
||||
|
||||
f = open("data/data.txt", "r")
|
||||
text = f.read()
|
||||
with open("data/data.txt", "r") as f:
|
||||
text = f.read()
|
||||
|
||||
text_model = markovify.Text(text)
|
||||
message = ''
|
||||
@@ -18,6 +24,8 @@ message = ''
|
||||
for i in range(5):
|
||||
message = message + text_model.make_sentence()
|
||||
|
||||
with TelegramClient('bot', api_id, api_hash) as client:
|
||||
if (dry_run):
|
||||
print(message)
|
||||
else:
|
||||
with TelegramClient('bot', api_id, api_hash) as client:
|
||||
client.send_message(entity=entity, message=message)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
markovify
|
||||
telethon
|
||||
python-dotenv
|
||||
argparse
|
||||
|
||||
Reference in New Issue
Block a user