Skip to content

Instantly share code, notes, and snippets.

@Mictronics
Created April 28, 2024 12:12
Show Gist options
  • Save Mictronics/1dffc6aea19fcde3afe059470dd21809 to your computer and use it in GitHub Desktop.
Save Mictronics/1dffc6aea19fcde3afe059470dd21809 to your computer and use it in GitHub Desktop.
Python script forwarding Gammu service caller ID to Telegram
#!/usr/bin/env python3
import asyncio
import os
import sys
import telegram
from datetime import datetime
async def main():
if len(sys.argv) == 1:
print("Phone number missing")
sys.exit(0)
elif len(sys.argv) == 2:
now = datetime.now()
# Log
text = f"\u260e {sys.argv[1]} @ {now.strftime('%d.%m.%Y %H:%M:%S')}"
print(text)
#Send by Telegram
bot = telegram.Bot(token='[your bot token]')
async with bot:
await bot.send_message(chat_id=[your chat ID], text=text)
if __name__ == "__main__":
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment