Last active
October 24, 2020 03:03
-
-
Save RedL0tus/1bfc79549c6ee6df2bcd0cf5190a95c4 to your computer and use it in GitHub Desktop.
Real time nick (systemd timer version)
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
[Unit] | |
Description=Telegram nickname updater | |
After=network-online.target | |
[Service] | |
User=yourname | |
Type=oneshot | |
WorkingDirectory=/path/to/updater | |
ExecStart=/path/to/updater/venv/bin/python3 /path/to/updater/updater.py |
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
[Unit] | |
Description=Update Telegram nickname every minute | |
[Timer] | |
OnCalendar=*:0/1 | |
Persistent=true | |
[Install] | |
WantedBy=timers.target |
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 | |
# -*- encoding: utf-8 -*- | |
import time | |
FIRST_NAME = '咸鱼' | |
LAST_NAME = '@ %H:%M GMT' # Follow the rules of Python's strftime | |
START_TIME = time.time() | |
from pyrogram import Client, api | |
def update_name(client): | |
client.send( | |
api.functions.account.UpdateProfile( | |
first_name=time.strftime(FIRST_NAME, time.gmtime()), | |
last_name=time.strftime(LAST_NAME, time.gmtime()) | |
) | |
) | |
print('>>> Name updated.') | |
if __name__ == '__main__': | |
app = Client("real-time-nick") | |
with app: | |
update_name(app) | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment