Guest User

Untitled

a guest
Dec 11th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. import xchat
  2. #*nix specific module, doesn't matter, audacious is *nix specific anyway. (I think)
  3. import commands
  4.  
  5. audtool_prog = "audtool2"
  6. audtool_alternative = "audtool"
  7. prog_check = "which"
  8. bold_char = '\002'
  9.  
  10. #does audtool exist
  11. def audacious_check():
  12. global audtool_prog, prog_check, audtool_alternative
  13. exists = commands.getstatusoutput(prog_check + " " + audtool_prog)
  14. if (exists[0] == 0):
  15. return True
  16. #check for aud 1
  17. exists = commands.getstatusoutput(prog_check + " " + audtool_alternative)
  18. if (exists[0] == 0):
  19. audtool_prog = audtool_alternative
  20. return True
  21. return False
  22.  
  23. #perform shout
  24. def shout(word, word_eol, userdata):
  25. global bold_char, audtool_prog
  26. current = xchat.get_context()
  27. if audacious_check():
  28. #playing?
  29. playing = commands.getstatusoutput(audtool_prog + " playback-playing")
  30. if (playing[0] == 0):
  31. song = commands.getoutput(audtool_prog + " current-song")
  32. total = commands.getoutput(audtool_prog + " current-song-length")
  33. artist = commands.getoutput(audtool_prog + " current-song-tuple-data artist")
  34. output = commands.getoutput(audtool_prog + " current-song-output-length")
  35. final = bold_char + "Now Playing: " + bold_char + song + " by " + artist + " (" + output + "/" + total + ")" + " on Audacious"
  36. #make sure it's not in a server window
  37. if ((current.get_info("channel") != current.get_info("server")) and (current.get_info("channel") != current.get_info("network"))):
  38. #Say it.
  39. xchat.command("msg " + current.get_info("channel") + " " + final)
  40. else:
  41. #Print it
  42. current.prnt(final)
  43. else:
  44. current.prnt("Check that Audacious is playing!")
  45. else:
  46. current.prnt("Check that you have Audacious installed and audtool_prog set properly!")
  47. #accept the command no matter what happens, to prevent unknown command messages
  48. return xchat.EAT_XCHAT
  49.  
  50. if audacious_check():
  51. xchat.hook_command("audacious", shout, help="/audacious - Sends currently playing information to current context.")
  52. xchat.prnt("Audacious Shout plugin loaded!")
  53. else:
  54. xchat.prnt("Please check that Audacious is installed and audtool_prog is set properly. Plugin not loaded!")
Add Comment
Please, Sign In to add comment