Created
June 11, 2023 06:40
-
-
Save nuhmanpk/e2e49a30ea0174dd88fbea3be7eeffd0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyrogram | |
import pywhatkit | |
# Replace with your Pyrogram API credentials | |
API_ID = 'YOUR_API_ID' | |
API_HASH = 'YOUR_API_HASH' | |
BOT_TOKEN = 'YOUR_BOT_TOKEN' | |
# Initialize the Pyrogram client | |
app = pyrogram.Client('my_bot', api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN) | |
# Handler for incoming messages | |
@app.on_message() | |
def handle_message(client, message): | |
# Get the text message | |
text = message.text | |
# Convert text to handwriting and save as image | |
image_filename = f'handwriting_{message.message_id}.png' | |
pywhatkit.text_to_handwriting(text, save_to=image_filename) | |
# Reply to the user with the image | |
client.send_photo(chat_id=message.chat.id, photo=image_filename) | |
# Cleanup: delete the image file | |
os.remove(image_filename) | |
# Start the bot | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[API_ID = 'YOUR_API_ID' API_HASH = 'YOUR_API_HASH' BOT_TOKEN = 'YOUR_BOT_TOKEN' # Initialize the Pyrogram client app = pyrogram.Client('my_bot', api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN)](API_ID = 'YOUR_API_ID' API_HASH = 'YOUR_API_HASH' BOT_TOKEN = 'YOUR_BOT_TOKEN' # Initialize the Pyrogram client app = pyrogram.Client('my_bot', api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN))