Created
April 28, 2024 12:12
-
-
Save Mictronics/1dffc6aea19fcde3afe059470dd21809 to your computer and use it in GitHub Desktop.
Python script forwarding Gammu service caller ID to Telegram
This file contains 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
#!/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