This commit is contained in:
HarHar 2013-01-24 19:02:26 -02:00
commit 2a06996b86

View File

@ -17,10 +17,10 @@ class Bot(object):
# channel - channel to autojoin and interact with # channel - channel to autojoin and interact with
# channelPassword - if channel is +k # channelPassword - if channel is +k
# functions - list/tuple of functions that can be used from the bot: # functions - list/tuple of functions that can be used from the bot:
# * pause(setBy, room, state=bool) # * pause(setBy, state=bool)
# * getRooms() -> list # * getRooms() -> list
# * getPosition(room) -> int # * getPosition(room) -> int
# * setPosition(setBy, room, seconds) # * setPosition(setBy, seconds)
# * getUsers(room) -> list of {'nick': str, 'file': str, 'length': int} # * getUsers(room) -> list of {'nick': str, 'file': str, 'length': int}
# * isPaused(room) -> bool # * isPaused(room) -> bool
@ -127,41 +127,29 @@ class Bot(object):
else: else:
self.msg(to, chr(2) + 'Usage:' + chr(15) + ' !roominfo [room]') self.msg(to, chr(2) + 'Usage:' + chr(15) + ' !roominfo [room]')
elif split[0].lower() == '!pause': elif split[0].lower() == '!pause':
if len(split) >= 2:
rooms = self.functions[1]() rooms = self.functions[1]()
for room in split[1:]:
if (room in rooms) == False: for room in rooms:
self.msg(to, chr(3) + '5Error!' + chr(15) + ' Room does not exists (' + room + ')')
else:
users = self.functions[4](room) users = self.functions[4](room)
for u in users: for u in users:
if u['nick'] == nickFrom: if u['nick'] == nickFrom:
self.functions[6](nickFrom, True)
break break
else: else:
self.msg(to, chr(3) + '5Error!' + chr(15) + ' Your nick is not in the specified room') self.msg(to, chr(3) + '5Error!' + chr(15) + ' Your nick was not found on the server')
continue return
self.functions[6](nickFrom, room, True)
else:
self.msg(to, chr(2) + 'Usage:' + chr(15) + ' !pause [room]')
elif split[0].lower() == '!play': elif split[0].lower() == '!play':
if len(split) >= 2:
rooms = self.functions[1]() rooms = self.functions[1]()
for room in split[1:]:
if (room in rooms) == False: for room in rooms:
self.msg(to, chr(3) + '5Error!' + chr(15) + ' Room does not exists (' + room + ')')
else:
users = self.functions[4](room) users = self.functions[4](room)
for u in users: for u in users:
if u['nick'] == nickFrom: if u['nick'] == nickFrom:
self.functions[6](nickFrom, False)
break break
else: else:
self.msg(to, chr(3) + '5Error!' + chr(15) + ' Your nick is not in the specified room') self.msg(to, chr(3) + '5Error!' + chr(15) + ' Your nick was not found on the server')
continue return
self.functions[6](room, False)
else:
self.msg(to, chr(2) + 'Usage:' + chr(15) + ' !play [room]')
elif split[0].lower() == '!help': elif split[0].lower() == '!help':
self.msg(to, chr(2) + 'Available commands:' + chr(15) + ' !rooms / !roominfo [room] / !pause / !play') self.msg(to, chr(2) + 'Available commands:' + chr(15) + ' !rooms / !roominfo [room] / !pause / !play')