Sending Whatsapp Message in the text file - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Sending Whatsapp Message in the text file (/thread-37509.html) |
Sending Whatsapp Message in the text file - ebincharles869 - Jun-21-2022 Hello, I am sending whatsapp message through python. Below is the code. import pywhatkit pywhatkit.sendwhats_image("E9wnucCUpBpD1aizIUyLv6", "E:\\PythonFiles\\Music.jpg", "footer.txt", 10) pywhatkit.sendwhatmsg_to_group("E9wnucCUpBpD1aizIUyLv6", "Test", 13, 3, 15, True, 5)But i want to send a paragraph of message which is typed and saved in the same directory in text file. How can i code to take message from the text file. Thanks for the big help. regards, ebin RE: Sending Whatsapp Message in the text file - snippsat - Jun-21-2022 If pywhatkit don't take a file object you can do it like this. import pywhatkit with open("footer.txt") as f: pywhatkit.sendwhats_image("E9wnucCUpBpD1aizIUyLv6", "E:\\PythonFiles\\Music.jpg", f.read(), 10) pywhatkit.sendwhatmsg_to_group("E9wnucCUpBpD1aizIUyLv6", "Test", 13, 3, 15, True, 5) RE: Sending Whatsapp Message in the text file - ebincharles869 - Jun-21-2022 But i get error like this
(Jun-21-2022, 10:49 AM)snippsat Wrote: If pywhatkit don't take a file object you can do it like this. RE: Sending Whatsapp Message in the text file - snippsat - Jun-21-2022 You most have footer.txt in same folder as main.py. Or give path to where you have footer.txt. with open(r"C:\somefolder\footer.txt") as f: RE: Sending Whatsapp Message in the text file - ebincharles869 - Jun-21-2022 (Jun-21-2022, 11:27 AM)snippsat Wrote: You most have footer.txt in same folder as main.py. Below is the error i am receiving. I guess there should be string explained inside the bracket in f.read(). pywhatkit.sendwhatmsg_to_group("E9wnucCUpBpD1aizIUyLv6", f.read(), 15, 2)
RE: Sending Whatsapp Message in the text file - snippsat - Jun-21-2022 Windows is messing up choosing wrong encoding. Do this: with open("footer.txt", encoding='utf-8') as f: RE: Sending Whatsapp Message in the text file - ebincharles869 - Jun-21-2022 (Jun-21-2022, 12:22 PM)snippsat Wrote: Windows is messing up choosing wrong encoding. the above error comes for indented block after with statement.
RE: Sending Whatsapp Message in the text file - snippsat - Jun-21-2022 (Jun-21-2022, 12:44 PM)ebincharles869 Wrote: the above error comes for indented block after with statement.Yes,Python need indentation ๐ง import pywhatkit with open("footer.txt", encoding='utf-8') as f: pywhatkit.sendwhats_image("E9wnucCUpBpD1aizIUyLv6", "E:\\PythonFiles\\Music.jpg", f.read(), 10) pywhatkit.sendwhatmsg_to_group("E9wnucCUpBpD1aizIUyLv6", "Test", 13, 3, 15, True, 5) RE: Sending Whatsapp Message in the text file - ebincharles869 - Jun-21-2022 Its working Perfectly. Thank you. However it works only when there English texts. I need to insert some symbols like below and other languages texts. I hope the copy paste function works. Is that possible. โโจโฆ โโ๐นโโ โฆโจโ โผโผโโโโโโผ ๐๐ง๐โ๐ __๐ RE: Sending Whatsapp Message in the text file - snippsat - Jun-21-2022 It depend on what pywhatkit accept,it works from Python side. with open("test.txt", encoding='utf-8') as f: print(f.read()) Try different stuff and just one Emoji at time as test.print(f'\N{grinning face}') print(f'\N{eye}') emoji 1.7.0# pip install emoji import emoji print(emoji.emojize('Python is :thumbs_up:')) print(emoji.emojize('Python is fun :ghost:'))
|