split messages in discord notifications
This commit is contained in:
parent
ad3dcc2fdd
commit
c1470a1103
12
notify.py
12
notify.py
|
@ -7,9 +7,17 @@ async def main(target, message):
|
||||||
client = Client()
|
client = Client()
|
||||||
await client.login('your token')
|
await client.login('your token')
|
||||||
user = await client.fetch_user(target)
|
user = await client.fetch_user(target)
|
||||||
await user.send(message)
|
if len(message) > 250:
|
||||||
|
for i in range(len(message) // 1900 + 1):
|
||||||
|
await user.send(f'```{message[1900*i:1900*(i+1)]}```')
|
||||||
|
print(f'```{message[1900*i:1900*(i+1)]}```')
|
||||||
|
else:
|
||||||
|
await user.send(message)
|
||||||
await client.logout()
|
await client.logout()
|
||||||
await client.close()
|
await client.close()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
loop = asyncio.get_event_loop().run_until_complete(main(*argv[1:]))
|
try:
|
||||||
|
loop = asyncio.get_event_loop().run_until_complete(main(*argv[1:]))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue
Block a user