Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit c25e7c8

Browse files
authored
Merge pull request #266 from Namyalg/Automate-Telegram
Scripts to automate sending messages in Telegram from command line
2 parents 4be0c24 + f2c6a8b commit c25e7c8

File tree

10 files changed

+72
-103
lines changed

10 files changed

+72
-103
lines changed
-48.7 KB
Binary file not shown.

Image-Processing/Sobel-edge-detection/README.md

-27
This file was deleted.
-216 KB
Binary file not shown.

Image-Processing/Sobel-edge-detection/sobel-edge-detect.py

-76
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Automate Telegram
2+
- This script can be used to automate the process of sending messages in Telegram
3+
- Here the process of automation is achieved by using the framework Selenium.
4+
- Selenium is a portable framework for testing and automating web applications web applications
5+
6+
## Working
7+
8+
![Image](login.png)
9+
10+
- The user is prompted to login and verify the phone number
11+
12+
- The user will receive a code which has to be entered
13+
14+
![Image](code.png)
15+
16+
- After the verification process, the user can send messages to the contacts
17+
18+
![Image](send.png)
19+
20+
- The user can send multiple messages to the same user
21+
22+
- The user can also send messages to multiple users
23+
24+
![Image](working.PNG)
25+
26+
- An message sent from the commandline
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#Imports and dependencies
2+
from selenium import webdriver
3+
import time
4+
from selenium.webdriver.common.keys import Keys
5+
6+
time_wait_sixty = 60
7+
time_wait_four = 4
8+
9+
#Here the process of automation is achieved by using the framework Selenium.
10+
#Selenium is a portable framework for testing and automating web applications web applications
11+
12+
def automate_telegram():
13+
#Path to the chromedriver must be entered without quotations
14+
PATH = input("Enter path to the location chromedriver ")
15+
chrome_path = PATH
16+
#Initiating and setting up the driver
17+
driver = webdriver.Chrome(chrome_path)
18+
#For logging into web telegram, the user must verify the phone number
19+
URL = "https://web.telegram.org/#/login"
20+
driver.get(URL)
21+
time.sleep(time_wait_sixty)
22+
user = 1
23+
while user:
24+
driver.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[1]/div[1]/div/input").click()
25+
name = input("Enter the name of the person ")
26+
driver.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[1]/div[1]/div/input").send_keys(name)
27+
time.sleep(time_wait_four)
28+
driver.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[1]/div[2]/div/div[1]/ul/li").click()
29+
msg = 1
30+
while msg:
31+
message = input("Enter message ")
32+
driver.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[2]/div[3]/div/div[3]/div[2]/div/div/div/form/div[2]/div[5]").send_keys(message)
33+
driver.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[2]/div[3]/div/div[3]/div[2]/div/div/div/form/div[2]/div[5]").send_keys(Keys.ENTER)
34+
print("Do you want to send another message? ")
35+
msg = int(input("Enter 1 to continue, 0 to stop "))
36+
if msg == 0:
37+
break
38+
39+
print("Do you want to send messages to another contact? ")
40+
user = int(input("Enter 1 to continue, 0 to stop "))
41+
42+
return("All messages sent")
43+
44+
if __name__ == "__main__":
45+
automate_telegram()
46+
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)