Author: Not specified Language: text
Description: Not specified Timestamp: 2013-05-17 17:51:51 +0000
View raw paste Reply
  1. import web, json, threading
  2.  
  3. def setup(self):
  4.     # watchlobby(self)
  5.     pass
  6.  
  7. def watchlobby(phenny):
  8.     uri = 'http://www.lf2lobby.com:8000/roomlist/'
  9.     try:
  10.         bytes = web.get(uri)
  11.        
  12.         # Current games: popsicle(Zort, Doix, YinYin, Empty), hitlerwasright(krs, fiol)
  13.         msg = 'Current games:'
  14.        
  15.         # [{"__type":"RoomInfo:#dummy_lf2_client","GameName":"woof","MaxPlayers":2,"OwnerName":"woofwoof","Players":1}
  16.         roomlist = json.loads(bytes)
  17.         if roomlist:
  18.             for room in roomlist:
  19.                 msg += ' %1(%2 out of %3 players),'.format(room['GameName'],
  20.                                                            room['Players'],
  21.                                                            room['MaxPlayers'])
  22.             msg = msg[:-1]
  23.  
  24.             phenny.msg('#tankbobz', msg)
  25.     except IOError:
  26.         phenny.msg('#tankbobz', "Lobby roomlist not responding.")
  27.    
  28.     phenny.lobbytimer = threading.Timer(2*60*60, watchlobby(phenny), args=[phenny])
  29.  
  30. def shutup(phenny, input):
  31.     if hasattr(phenny, '__lobbytimer__'):
  32.         try:
  33.             phenny.lobbytimer.cancel()
  34.             phenny.say("Ok, shutting up about lobby.")
  35.         except Exception, e:
  36.             phenny.say("Error shutting up, terribly sorry.")
  37.             raise e
  38.     else:
  39.         phenny.reply("What?")
  40. shutup.rule = r'zorbot:? [Ss]hut ?up\.?'
  41. shutup.example = 'zorbot: shut up'
  42.  
  43. if __name__ == '__main__':
  44.     print('Hi! Don\'t run me standalone!')
  45.  
View raw paste Reply