note=modnote, act=ban)) return reply.response(error) def unbanthing(bot, cmd, msg, user, room): reply = ReplyObject('', True, True) if not user.hasRank('#'): return reply.response( 'You do not have permission to do this. (Requires #)') if room.isPM: return reply.response("You can't unban things in PMs") error = room.moderation.removeBan(cmd[5:], msg) if not error: return reply.response( 'Removed {thing} from the banlist {room}\n/modnote {user} removed {thing} from the blacklist' .format(thing=msg, room=room.title, user=user.name)) return reply.response(error) # Exports handlers = { 'c': moderationHandler, 'chat': moderationHandler, 'c:': timestampModerationHandler } commands = [ Command(['moderate'], moderate), Command(['banuser', 'banphrase'], banthing), Command(['unbanuser', 'unbanphrase'], unbanthing) ]
def untourwl(bot, cmd, params, user, room): """ Independent command for removing a user from the tours whitelist. Reserved for room owners. Args: bot: PokemonShowdownBot, the instance of PokemonShowdownBot that called this function. cmd: string, the command that was send. room: Room, the room object that the command was sent from. params: string, the name of the user. user: User, the user object of the user who sent the command. Returns: ReplyObject. """ reply = ReplyObject('', True) if not user.hasRank('#'): return reply.response('You do not have permission to change this. (Requires #)') target = bot.toId(params) if not room.delFromWhitelist(target): return reply.response('This user is not whitelisted in that room.') bot.saveDetails() return reply.response('{name} removed from the whitelist in this room.'.format(name = params)) commands = [ Command(['leave'], leaveroom), Command(['allowgames'], allowgames), Command(['tour', '!tour'], tour), Command(['tourwhitelist', 'tourwl'], tourwl), Command(['untourwhitelist', 'untourwl'], untourwl), Command(['gettourwhitelist', 'gettourwl'], gettourwl) ]
formatData = roomData[parts[0]] format = parts.pop(0) try: userData = formatData[parts[0]] return reply.response('{user} has played {games} and won {wins} ({winrate:.1f}% win rate)'.format(user = parts[0], games = userData['entered'], wins = userData['won'], winrate = (userData['won'] / userData['entered']) * 100)) except IndexError: rankingsTable = Tournament.buildRankingsTable(formatData, format) if bot.canHtml(room): return reply.response('/addhtmlbox {}'.format(rankingsTable)) else: return reply.response('Cannot show full rankings in this room') except KeyError: return reply.response('{user} has no data for {tier} in {room}'.format(user = parts[0], tier = format, room = roomTitle if roomTitle else room.title)) except TypeError: return reply.response('The room {} has no data about rankings'.format(msg.split(',')[0])) except IndexError: return reply.response('No format given') except KeyError: return reply.response('The room has no data about the format {}'.format(parts[0])) # Exports handlers = { 'tournament': tourHandler, 'queryresponse': queryresponse } commands = [ Command(['oldgentour'], oldgentour), Command(['tourhistory'], tourhistory), Command(['showranking', 'leaderboard'], getranking) ]
A = res1[temp1][0] + res2[temp2][0] M = res1[temp1][1] + res2[temp2][1] temp = temp1 + " " + temp2 x = "The stats for " + temp + " are Attack:" + str(A) + " Magic:" + str(M) ## print(tempp) return ReplyObject(x) ##def hiback(robot,cmd): ## robot.say("battledome","hi there") ## return ReplyObject('') ## commands = [ # The easy stuff that can be done with a single lambda expression Command(['source', 'git'], lambda: ReplyObject( 'Source code can be found at: {url}'.format(url=URL()), True)), Command(['credits'], lambda: ReplyObject( 'Credits can be found: {url}'.format(url=URL()), True)), Command([ 'owner' ], lambda s: ReplyObject('Owned by: {owner}'.format(owner=s.owner), True)), Command(['commands', 'help'], lambda: ReplyObject( 'Read about commands here: {url}blob/master/COMMANDS.md'.format(url= URL()), reply=True, pmreply=True)), Command(['explain'], lambda: ReplyObject( "BB-8 is the name of a robot in the seventh Star Wars movie :)", True) ), Command(['ask'], lambda: ReplyObject(Lines[randint(0,
def read(bot, cmd, msg, user): reply = ReplyObject() notes = bot.usernotes if not notes.hasMessage(user.id): return reply.response('You have no messages waiting') if not msg: # If the user didn't speify any amount to return, give back a single message return reply.response(notes.getMessages(user.id, 1)) if not msg.isdigit() and int(msg) < 1: return reply.response('Please enter a positive integer') return reply.response(notes.getMessages(user.id, int(msg))) def untell(bot, cmd, msg, user): reply = ReplyObject() notes = bot.usernotes if not msg: return reply.response('You need to specify a user to remove') if not notes.hasMessage(msg): return reply.response('This user has no waiting messages') if not notes.removeMessage(msg, user.id): return reply.response('You have no message to this user waiting') return reply.response('Message removed') handlers = {'j': join} commands = [ Command(['tell'], tell), Command(['untell'], untell), Command(['read'], read) ]
def analysis(robot, cmd, params, user, room): cmd = params.split(' ')[0] params = params[len(cmd) + 1:] response = pokedex(robot, cmd, params, user, room) if robot.canHtml(room): return response.extra( '<br /><sub>This command also works without `analysis`, like {char}{pokemon}</sub>' .format(char=robot.commandchar, pokemon=cmd)) return response commands = [ # The easy stuff that can be done with a single lambda expression Command(['source', 'git'], lambda: ReplyObject( 'Source code can be found at: {url}'.format(url=URL()), True)), Command(['credits'], lambda: ReplyObject( 'Credits can be found: {url}'.format(url=URL()), True)), Command([ 'owner' ], lambda s: ReplyObject('Owned by: {owner}'.format(owner=s.owner), True)), Command(['commands', 'help'], lambda: ReplyObject( 'Read about commands here: {url}blob/master/COMMANDS.md'.format(url= URL()), reply=True, pmreply=True)), Command(['explain'], lambda: ReplyObject( "BB-8 is the name of a robot in the seventh Star Wars movie :)", True) ), Command(['ask'], lambda: ReplyObject(Lines[randint(0,
}) def addEvent(robot, cmd, params, user, room): reply = ReplyObject('', reply=True, pmreply=True) if not user.hasRank('#'): return reply.response( "Permission denied, only Room Owners (#) and up can use this command." ) with open('added-jobs.csv', 'a+') as jobs: jobs.write('{user},{job}\n'.format(user=user.id, job=params)) date, frequency, joblist = params.replace('| ', '|').split('|') # Validate date string format first if not EventScheduler.validateDateString(date): return reply.response( 'Invald date format. Expected format is YYYY/MM/DD HH:MM.') room.scheduler.addJob(date, frequency, joblist) return reply.response( 'New event scheduled for {date}, repeating every {freq} days.'.format( date=date, freq=frequency)) # Exports commands = [ Command(['initevents'], lambda s, c, p, u, r: ReplyObject( r.scheduler.configureEventScheduler(s))), Command(['addevent'], addEvent) ]
if not room.allowGames: return reply.response('This room does not support chatgames.') kind = 'first' if len(params) > 1: kind = params[1] if user.hasRank('@'): room.activity = Trivia(bot.ws, room.title, kind) return reply.response('A new trivia session has started.') return reply.response( 'You do not have permission to set up a trivia session') elif params[0] in ['stop', 'end']: # The trivia class will solve everything after doing this. room.activity.endSession = True room.activity = None return reply.response('The trivia session has been ended') if cmd == 'ta': if not (room.activity and room.activity.isThisGame(Trivia)): return reply.response('There is no ongoing trivia session.') # Don't give information if wrong or right here, let Trivia deal with that if room.activity.tryAnswer(msg): if not room.activity.solver: room.activity.wasSolved(user.name) else: room.activity.multiple = True return reply.response('NoAnswer') return reply.response('') commands = [Command(['trivia'], triviaCommands)]
# If the pasted team was an importable instead of packed, pack it if not team.startswith('|'): team = BattleHandler.PSPackTeam(team) # Double check so it actually is packed if not team.startswith('|'): return reply.response( "This team doesn't look like a valid packed team :(") meta = bot.toId(meta) if not meta in bot.bh.teams: bot.bh.teams[meta] = [] if not team in bot.bh.teams[meta]: bot.bh.teams[meta].append(team) else: return reply.response('I already have that team! :D') if not meta in bot.bh.supportedFormats: bot.bh.supportedFormats.append(meta) with open('plugins/battling/teams.yaml', 'w+') as file: yaml.dump(bot.bh.teams, file, default_flow_style=False, explicit_start=True) return reply.response( 'Saved that team for you so that I can play with it :)') commands = [ Command(['storeteam'], acceptTeam), Command(['ladder'], startLaddering) ]
if msg: return reply.response( '{param} is not a valid parameter for ~anagram. Make guesses with ~a' .format(param=msg)) if room.activity and room.activity.isThisGame(Anagram): return reply.response( 'Current anagram: {word}'.format(word=room.activity.getWord())) return reply.response('There is no active anagram right now') def answer(bot, cmd, msg, user, room): reply = ReplyObject('', True, False, False, True, True) if not (room.activity and room.activity.isThisGame(Anagram)): return reply.response('There is no anagram active right now') if room.activity.isCorrect(re.sub(r'[ -]', '', msg).lower()): solved = room.activity.getSolvedWord() timeTaken = room.activity.getSolveTimeStr() room.activity = None # Save score Scoreboard[user.id] = 1 if user.id not in Scoreboard else Scoreboard[ user.id] + 1 with open('plugins/scoreboard.yaml', 'w') as ym: yaml.dump(Scoreboard, ym) return reply.response( 'Congratulations, {name} got it{time}\nThe solution was: {solution}' .format(name=user.name, time=timeTaken, solution=solved)) return reply.response('{test} is wrong!'.format(test=msg.lstrip())) commands = [Command(['anagram'], start), Command(['a'], answer)]
) return reply.response(workshop.removePokemon(msg[7:].strip())) elif msg == 'clear': if not workshop.hasHostingRights(user): return reply.response( 'Only the workshop host or a Room Moderator can clear the team' ) return reply.response(workshop.clearTeam()) elif msg == 'team': return reply.response(workshop.getTeam()) elif msg == 'end': if not workshop.hasHostingRights(user): return reply.response( 'Only the workshop host or a Room Moderator can end the workshop' ) bot.sendPm(user.id, workshop.pasteLog(room.title, bot.apikeys['pastebin'])) room.activity = None return reply.response('Workshop session ended') return reply.response( 'Unrecognized command: {cmd}'.format(cmd=msg if msg else 'nothing')) handler = { 'c': workshopHandler, 'chat': workshopHandler, 'c:': timestampWorkshopHandler } commands = [Command(['workshop', 'ws'], commands)]
'Only the workshop host or a Room Moderator can add Pokemon') return reply.response(workshop.addPokemon(msg[4:].strip())) elif msg.startswith('remove'): if not workshop.hasHostingRights(user): return reply.response( 'Only the workshop host or a Room Moderator can remove Pokemon' ) return reply.response(workshop.removePokemon(msg[7:].strip())) elif msg == 'clear': if not workshop.hasHostingRights(user): return reply.response( 'Only the workshop host or a Room Moderator can clear the team' ) return reply.response(workshop.clearTeam()) elif msg == 'team': return reply.response(workshop.getTeam()) elif msg == 'end': if not workshop.hasHostingRights(user): return reply.response( 'Only the workshop host or a Room Moderator can end the workshop' ) bot.sendPm(user.id, workshop.pasteLog(room.title, bot.apikeys['pastebin'])) room.activity = None return reply.response('Workshop session ended') return reply.response( 'Unrecognized command: {cmd}'.format(cmd=msg if msg else 'nothing')) commands = [Command(['workshop', 'ws'], handler)]