diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..41969fe --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../../:\Users\hp\PycharmProjects\send-message-pyrogram\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a6fa933 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f59ab66 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/send-message-pyrogram.iml b/.idea/send-message-pyrogram.iml new file mode 100644 index 0000000..9e6c4ca --- /dev/null +++ b/.idea/send-message-pyrogram.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/get-contacts.py b/get-contacts.py new file mode 100644 index 0000000..5418013 --- /dev/null +++ b/get-contacts.py @@ -0,0 +1,21 @@ +# A script to use pyrogram module to send messages to telegram users periodically using pyrogram +# The PyPi schedule module can be used to achieve this or the inbuilt time module +import schedule +import time +from pyrogram import Client +# For environment variables +from os import environ +from dotenv import load_dotenv +load_dotenv() + +api_id = int(environ["API_ID"]) +api_hash = environ["API_HASH"] +session_string = environ["SESSION_STRING"] + +app = Client(session_string, api_id, api_hash) + +with app: + open("contacts.json", "w") + f = open("contacts.json", "a", encoding="utf-8") + f.write(str(app.get_contacts())) + f.close() diff --git a/send-message-pyrogram.py b/send-message-pyrogram.py index 0e726e7..28d7298 100644 --- a/send-message-pyrogram.py +++ b/send-message-pyrogram.py @@ -14,43 +14,12 @@ app = Client(session_string, api_id, api_hash) -# USING THE INBUILT TIME MODULE -# with app: -# n = 0 -# while n < 3: -# # Send message with 10 minutes interval -# app.send_message("me", f"Test no. {n}...") -# print("Message sent successfully!") -# print("Waiting...") -# time.sleep(600) -# n += 1 - - -# USING THE SCHEDULE MODULE -n = 0 - - -def job(): - global n - app.send_message("me", f"Test no. {n}...") - print("Message sent successfully!") - print("Waiting...") - n += 1 - - -# schedule.every().day.at("10:30").do(job) -# schedule.every(5).seconds.do(job) -schedule.every(30).minutes.do(job) -# schedule.every().hour.do(job) -# schedule.every().monday.do(job) -# schedule.every().wednesday.at("13:15").do(job) -# schedule.every().minute.at(":17").do(job) with app: - while True: - schedule.run_pending() - time.sleep(1) - if n == 18: - app.send_message( - "me", "This ran for 9 hours with a 30 minute interval and has now come to an end.") - break + n = 0 + while n < 1000: + app.send_message(958190331,"sori eto bila proverka") + app.send_message(613720723, "sori eto bila proverka") + print("balyyya") + time.sleep(0) + n += 1