Guest User

Untitled

a guest
Apr 24th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #coding=utf8
  3.  
  4. # Imports #
  5. import codecs
  6. import weechat
  7. import subprocess
  8. import commands
  9. import time
  10.  
  11. # Register #
  12. weechat.register('wmii-notify', '0.0.1', 'close',
  13. 'Notify plugin for the wmii /rbar')
  14.  
  15. # Handlers #
  16. weechat.add_message_handler('weechat_highlight', 'on_hl')
  17. weechat.add_message_handler('weechat_pv', 'on_pv')
  18.  
  19. # Functions #
  20. def bar_reset():
  21. bar_write(":weechat:", "write")
  22.  
  23. def bar_write(buf, verb):
  24. bar_stdin = subprocess.Popen(["wmiir", verb, "/rbar/100"],
  25. stdin=subprocess.PIPE).stdin
  26. bar_stdin.write(buf)
  27. bar_stdin.close()
  28.  
  29. def on_hl(server, data):
  30. bar_write(data, "write")
  31. time.sleep(5)
  32. bar_reset()
  33. return weechat.PLUGIN_RC_KO
  34.  
  35. def on_pv(server, data):
  36. bar_write(data, "write")
  37. time.sleep(5)
  38. bar_reset()
  39. return weechat.PLUGIN_RC_KO
  40.  
  41. def bar_reset():
  42. bar_write(":weechat:", "write")
  43.  
  44. # Init #
  45. def bar_init():
  46. bar_write(":weechat:", "create")
  47.  
  48. bar_init()
  49.  
  50. # Exit #
  51. def close():
  52. commands.getoutput(["wmiir", "remove", "/rbar/100"])
Add Comment
Please, Sign In to add comment