Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.9 KiB

4 years ago
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Script Name: aesthetic.py
  4. # Script Author: Wojciech Siewierski
  5. # Script License: GPL3
  6. # Contact: vifon @ irc.freenode.net
  7. SCRIPT_NAME = 'aesthetic'
  8. SCRIPT_AUTHOR = 'Wojciech Siewierski'
  9. SCRIPT_VERSION = '1.0.6'
  10. SCRIPT_LICENSE = 'GPL3'
  11. SCRIPT_DESC = 'Make messages more A E S T H E T I C A L L Y pleasing.'
  12. import_ok = True
  13. try:
  14. import weechat
  15. except ImportError:
  16. print('This script must be run under WeeChat')
  17. print('You can obtain a copy of WeeChat, for free, at https://weechat.org')
  18. import_ok = False
  19. weechat_version = 0
  20. import shlex
  21. import sys
  22. def aesthetic_(args):
  23. for arg in args:
  24. try:
  25. arg = arg.decode('utf8')
  26. except AttributeError:
  27. pass
  28. yield " ".join(arg.upper())
  29. for n, char in enumerate(arg[1:]):
  30. yield " ".join(" "*(n+1)).join(char.upper()*2)
  31. def aesthetic(args):
  32. if sys.version_info < (3,):
  33. return (x.encode('utf8') for x in aesthetic_(args))
  34. else:
  35. return aesthetic_(args)
  36. def aesthetic_cb(data, buffer, args):
  37. for x in aesthetic(shlex.split(args)):
  38. weechat.command(buffer, x)
  39. return weechat.WEECHAT_RC_OK
  40. if __name__ == "__main__" and import_ok:
  41. if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
  42. weechat_version = weechat.info_get("version_number", "") or 0
  43. weechat.hook_command(
  44. "aesthetic",
  45. """Format a message like this:
  46. E X A M P L E
  47. X X
  48. A A
  49. M M
  50. P P
  51. L L
  52. E E
  53. Each argument is formatted separately, use sh-like quotes for grouping. For example '/aesthetic foo bar' will send two such blocks while '/aesthetic "foo bar"' would send one larger one.
  54. Use with care to not cause undesirable message spam.""",
  55. "message", "",
  56. "",
  57. "aesthetic_cb", ""
  58. )