Skip to content

Instantly share code, notes, and snippets.

@nuhmanpk
Created June 11, 2023 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuhmanpk/e2e49a30ea0174dd88fbea3be7eeffd0 to your computer and use it in GitHub Desktop.
Save nuhmanpk/e2e49a30ea0174dd88fbea3be7eeffd0 to your computer and use it in GitHub Desktop.
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()
@damiomuthliang
Copy link

[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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment