Guest User

Untitled

a guest
Jun 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #responds to .np with currently playing song
  2. def hook_OnPrivmsg_nowplaying(thread, event, user, target, message):
  3.     if message == '.np':
  4.         if target[0] != '#':
  5.             # if it's not sent to channel, reply to user
  6.             target = thread.user(user).nick
  7.         h = httplib.HTTPConnection('eden')
  8.         h.request('GET','/wordpress/np.php')
  9.         hr = h.getresponse()
  10.         if hr.status != 200:
  11.             thread.send('PRIVMSG %s :Error retrieving now playing information.' % target)
  12.             return True
  13.         e = xml.etree.ElementTree.XML(hr.read())
  14.         listeners = e.find('listeners').text
  15.         current = _striphtml(e.find('current').text)
  16.         thread.send('PRIVMSG %s :4Listeners: %s, 4Now Playing: %s' % (target, listeners, current))
  17.     return True
Add Comment
Please, Sign In to add comment