- Lolz
- Автор темы
- Команда форума
- 175
Скрипт добавляет время к нику
Библиотека:
pip install telethon
Код config.ini
Код:
[Telegram]
api_id = 1234567890
api_hash = '1234567890'
Код main.py
from telethon import TelegramClient, events
from telethon.tl.functions.account import UpdateProfileRequest
import datetime
import asyncio
import configparser
config = configparser.ConfigParser()
config.read("config.ini")
api_id = config['Telegram']['api_id']
api_hash = config['Telegram']['api_hash']
client = TelegramClient('anon', api_id, api_hash)
client.start()
async def main():
print('Start')
while True:
offset = datetime.timedelta(hours=5)
tz = datetime.timezone(offset)
time1 = datetime.datetime.now(tz)
current_time = time1.strftime("%H:%M")
await client(UpdateProfileRequest(last_name=current_time))
await asyncio.sleep(60)
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main())
Библиотека:
pip install telethon
Код config.ini
Код:
[Telegram]
api_id = 1234567890
api_hash = '1234567890'
Код main.py
from telethon import TelegramClient, events
from telethon.tl.functions.account import UpdateProfileRequest
import datetime
import asyncio
import configparser
config = configparser.ConfigParser()
config.read("config.ini")
api_id = config['Telegram']['api_id']
api_hash = config['Telegram']['api_hash']
client = TelegramClient('anon', api_id, api_hash)
client.start()
async def main():
print('Start')
while True:
offset = datetime.timedelta(hours=5)
tz = datetime.timezone(offset)
time1 = datetime.datetime.now(tz)
current_time = time1.strftime("%H:%M")
await client(UpdateProfileRequest(last_name=current_time))
await asyncio.sleep(60)
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main())