Guest User

Untitled

a guest
Jul 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # encoding: utf-8
  3.  
  4. import discord
  5. from discord.ext import commands
  6.  
  7. import io
  8.  
  9. from patch import global_message_send_hook
  10.  
  11.  
  12. bot = commands.Bot(command_prefix=commands.when_mentioned)
  13.  
  14. @global_message_send_hook
  15. async def attach_if_too_long(original_send, message=None, *args, **kwargs):
  16. if message is None: return True
  17.  
  18. message = str(message)
  19.  
  20. if len(message) > 2000:
  21. file = discord.File(fp=io.StringIO(message), filename='message.txt')
  22. await original_send('Way too long. Message attached.', *args, **kwargs, file=file)
  23. return False
  24.  
  25. return True
  26.  
  27. @bot.command()
  28. async def send_big_message(context):
  29. await context.send('Aa'*1001)
  30.  
  31. @bot.event
  32. async def on_ready():
  33. print('Ready.')
  34.  
  35.  
  36. if __name__ == '__main__':
  37. import os
  38.  
  39. bot.run(os.environ['discord_bot_token'])
Add Comment
Please, Sign In to add comment