def main(message: Message, discord_object: DiscordBot.DiscordBot): message_data = discord_object.parse_message(message.content) if len(message_data) == 2: name = message_data[1] ss = 'oceaniaGuildActivity' ws = 'Oceania' local_id = discord_object.locals[COMMAND][ss][ws]['discordID'] local_name = discord_object.locals[COMMAND][ss][ws]['Capitalized'] local_ez = discord_object.locals[COMMAND][ss][ws]['eznameUpper'] if str(message.author.id) in local_id: index = discord_object.locals[COMMAND][ss][ws]['discordID'].index( str(message.author.id)) name = discord_object.locals[COMMAND][ss][ws]['Name'][index] yield from discord_object.send_message( message.channel, message.author.mention + ' You are already registered as {}.'.format(name)) elif (name.upper() in local_name and local_id[local_name.index(name.upper())] != '') or ( name.upper() in local_ez and local_id[local_ez.index(name.upper())] != ''): yield from discord_object.send_message( message.channel, message.author.mention + ' {} is already a registered IGN.'.format(name)) else: editable = yield from discord_object.send_message( message.channel, message.author.mention + ' You are about to be registered as {}. Type *confirm to continue or *cancel to cancel.' .format(name)) yield from get_reply(message, discord_object, editable)
def main(message, discord_object: DiscordBot.DiscordBot): try: pdr_values = [ int(x) for x in message.content[len('*pdr '):].split(' ') ] for value in pdr_values: if value >= 100 or value < 0: yield from discord_object.send_message( message.channel, message.author.mention + ' Invalid pdr sources (values not between 1 and 99)') return base_pdr = pdr_values[0] / 100 for value in pdr_values[1:]: base_pdr = 1 - ((1 - base_pdr) * (100 - value) / 100) base_pdr = float(round(base_pdr * 100, 2)) yield from discord_object.send_message( message.channel, message.author.mention + ' Your pdr is: {}%'.format(str(base_pdr))) except Exception as e: if isinstance(e, ValueError): yield from discord_object.send_message( message.channel, message.author.mention + ' Invaid pdr sources (not integer values)') return pass
def main(message: Message, discord_object: DiscordBot.DiscordBot): try: delete_amount = int(discord_object.parse_message(message.content)[1]) if not (type(delete_amount) is int): raise IndexError yield from discord_object.send_message(message.channel, message.author.mention + ' You are about to clear messages in this channel. Type *confirm to proceed or *cancel to cancel.') yield from get_reply(message, discord_object, delete_amount) except IndexError: yield from discord_object.send_message(message.channel, message.author.mention + ' You did not specify a max number of messages to delete.')
def fetch_data_to_local(discord_object: DiscordBot.DiscordBot): ss = 'oceaniaGuildActivity' spreadsheet = {ss: {'Oceania': {}}} thread_pool = [] discord_object.spreadsheet_accessor.open_spreadsheet( ss, 'https://docs.google.com/spreadsheets/d/1VWg6INme20CV9BJnhgCLYbtlwnC3xl41Opz8Tzq9Auo/edit#gid=0' ) discord_object.spreadsheet_accessor.open_worksheet(ss, 'Oceania') arguments = [(ss, 'Oceania', 1, 1, False), (ss, 'Oceania', 2, 1, False), (ss, 'Oceania', 4, 1, False), (ss, 'Oceania', 6, 1, False), (ss, 'Oceania', 7, 1, False)] pointer = [['Oceania', 'Name'], ['Oceania', 'Capitalized'], ['Oceania', 'discordID'], ['Oceania', 'ezname'], ['Oceania', 'eznameUpper']] spreadsheet[ss]['Oceania']['lastpos'] = len( discord_object.spreadsheet_accessor.get_column_values( ss, 'Oceania', 1, 0, True)) discord_object.locals[COMMAND] = spreadsheet for x, argument in enumerate(arguments): thread = Thread(target=load_data, args=(discord_object, argument, pointer[x])) thread.setName(pointer[x][1]) thread_pool.append(thread) thread.start() while len(thread_pool) > 0: removable = [] for thread in thread_pool: if not thread.is_alive(): removable.append(thread) for x in removable: print('thread ' + x.getName() + ' completed') thread_pool.pop(thread_pool.index(x))
def main(message, discord_object: DiscordBot.DiscordBot): non_default = discord_object.json_data['Commands']['on_join']['User-Defined'] _default = discord_object.json_data['Commands']['on_join']['Default-Message'] if non_default is not None: val = non_default else: val = _default yield from discord_object.send_message(message.channel, message.author.mention + ' on_join message:\n' + val)
async def confirmed(message: Message, discord_object: DiscordBot.DiscordBot, delete_amount): for x in range(2): t = threading.Thread(target=message_worker, args=(discord_object, )) t.daemon = True t.start() async for x in discord_object.logs_from(message.channel, limit=delete_amount): local_data_queue.put(x)
def main(message: Message, discord_object: DiscordBot.DiscordBot): user = message.author isMember = False NSFW = discord.utils.get(message.server.roles, name='Guilty Eyes') for role in user.roles[1:]: if role == NSFW: isMember = True if not isMember: yield from discord_object.add_roles(user, NSFW) yield from discord_object.send_message( message.channel, user.mention + ' You now have access to the NSFW channel.') else: yield from discord_object.remove_roles(user, NSFW) yield from discord_object.send_message( message.channel, user.mention + ' Your access to the NSFW channel has been revoked.')
def pos(message: Message, discord_object: DiscordBot.DiscordBot): message_data = discord_object.parse_message(message.content) if len(message_data) == 2: boss_list = BOSSES elif len(message_data) == 3: boss_list = message_data[2] else: raise TypeError('Incorrect number of arguments') in_boss = {} try: name_index = discord_object.locals['register']['oceaniaGuildActivity'][ 'Oceania']['discordID'].index(message.author.id) name = discord_object.locals['register']['oceaniaGuildActivity'][ 'Oceania']['Name'][name_index] unrecognized = [] for boss in boss_list: if boss in CRA: sheet = 'CRA' else: sheet = 'OTHER' try: if name in discord_object.locals[COMMAND]['oceaniaCarryQueue'][ sheet][boss]: in_boss[boss] = discord_object.locals[COMMAND][ 'oceaniaCarryQueue'][sheet][boss].index(name) except KeyError: unrecognized.append(boss) continue msg = ' You are currently in the boss queue for:\n```' for key in in_boss.keys(): msg += '{}:{}{}\n'.format(NAMES[key], ''.join([' '] * (25 - len(NAMES[key]))), in_boss[key]) if len(unrecognized) > 0: msg += '```The following bosses were not recognized: {}'.format( ', '.join(unrecognized)) else: msg += '```' yield from discord_object.send_message(message.channel, message.author.mention + msg) except ValueError: yield from discord_object.send_message( message.channel, message.author.mention + ' You are not currently registered!')
def get_reply(message: Message, discord_object: DiscordBot.DiscordBot, editable): reply = yield from discord_object.wait_for_message(author=message.author, channel=message.channel) if reply.content == '*confirm': yield from confirmed(message, discord_object, editable) elif reply.content == '*cancel': pass else: yield from get_reply(message, discord_object, editable)
def get_reply(message: Message, discord_object: DiscordBot.DiscordBot, delete_amount, limit=10, count=0): if count < limit: count += 1 reply = yield from discord_object.wait_for_message(author=message.author, channel=message.channel) if reply.content == '*confirm': yield from confirmed(reply, discord_object, delete_amount) elif reply.content == '*cancel': pass else: yield from get_reply(message, discord_object, delete_amount, limit, count + 1)
def main(message: Message, discord_object: DiscordBot.DiscordBot): user = message.author isMember = False KritiasWatch = discord.utils.get(message.server.roles, name='Kritias Watch') for role in user.roles[1:]: if role == KritiasWatch: isMember = True if not isMember: yield from discord_object.add_roles(user, KritiasWatch) yield from discord_object.send_message( message.channel, user.mention + ' You have been added to the Kritias Invasion alert.') else: yield from discord_object.remove_roles(user, KritiasWatch) yield from discord_object.send_message( message.channel, user.mention + ' You have been removed from the Kritias Invasion alert.')
def main(message, discord_object: DiscordBot.DiscordBot): parameters = discord_object.parse_message(message.content)[1:] cwd = os.getcwd() os.chdir('commands/') yml_file = open('help.yml', 'r') data = yaml.load(yml_file) os.chdir(cwd) if len(parameters) > 0: if parameters[0] in data['help'].keys(): help_string = '' try: help_string = find_message(parameters, data['help']) if isinstance(help_string, dict): help_string = help_string['default'] except: pass if help_string != -1: formatted = discord_object.format_string(help_string, message) yield from discord_object.send_message(message.channel, formatted) else: base_string = discord_object.format_string(data['help']['help'], message) available = [] for c in discord_object.commands: if discord_object.has_permission(message.author.top_role, c) and c in data['help'].keys(): available.append(c) available.sort() commands = '`{}`'.format('`\n`'.join(available)) yield from discord_object.send_message(message.channel, base_string + '\n' + commands)
def edit(message, discord_object: DiscordBot.DiscordBot): message_structure = discord_object.parse_message(message.content) if len(message_structure) != 3: yield from discord_object.send_message(message.channel, 'Invalid syntax') else: discord_object.json_data['Commands']['on_join']['User-Defined'] = message_structure[-1] discord_object.update_json() yield from discord_object.send_message(message.channel, 'Done updating')
def fetch_data_to_local(discord_object: DiscordBot.DiscordBot): ss = 'oceaniaCarryQueue' thread_pool = [] spreadsheet = {ss: {'OTHER': {}, 'CRA': {}, 'CARRYLOG': {}}} discord_object.spreadsheet_accessor.open_spreadsheet( ss, 'https://docs.google.com/spreadsheets/d/1ojGWmWtgqZuwfSgIMJsvFf00DqayWoCJtwUhrYEmes8/edit#gid=1152797146' ) discord_object.spreadsheet_accessor.open_worksheet(ss, 'OTHER') discord_object.spreadsheet_accessor.open_worksheet(ss, 'CRA') discord_object.spreadsheet_accessor.open_worksheet(ss, 'CARRYLOG') arguments = [(ss, 'OTHER', 1, True), (ss, 'OTHER', 3, False), (ss, 'OTHER', 4, True), (ss, 'OTHER', 6, False), (ss, 'OTHER', 7, True), (ss, 'OTHER', 9, False), (ss, 'CRA', 1, True), (ss, 'CRA', 3, False), (ss, 'CRA', 4, True), (ss, 'CRA', 6, False), (ss, 'CRA', 7, True), (ss, 'CRA', 9, False), (ss, 'CRA', 10, True), (ss, 'CRA', 12, False)] pointer = [['OTHER', 'hmag'], ['OTHER', 'comment_hmag'], ['OTHER', 'hellux'], ['OTHER', 'comment_hellux'], ['OTHER', 'hhilla'], ['OTHER', 'comment_hhilla'], ['CRA', 'cq'], ['CRA', 'comment_cq'], ['CRA', 'cp'], ['CRA', 'comment_cp'], ['CRA', 'cvb'], ['CRA', 'comment_cvb'], ['CRA', 'cvel'], ['CRA', 'comment_cvel']] discord_object.locals[COMMAND] = spreadsheet print('starting threads') for x, argument in enumerate(arguments): thread = Thread(target=load_data, args=(discord_object, argument, pointer[x])) thread.setName(pointer[x][1]) thread_pool.append(thread) thread.start() while len(thread_pool) > 0: removable = [] for thread in thread_pool: if not thread.is_alive(): removable.append(thread) for x in removable: print('thread ' + x.getName() + ' completed') thread_pool.pop(thread_pool.index(x)) spreadsheet[ss]['CARRYLOG']['length'] = len( discord_object.spreadsheet_accessor.get_column_values( ss, 'CARRYLOG', 1))
def fetch_data_to_local(discord_object: DiscordBot.DiscordBot): ss = 'oceaniaGuildActivity' spreadsheet = {ss: {}} discord_object.spreadsheet_accessor.open_spreadsheet( ss, 'https://docs.google.com/spreadsheets/d/1VWg6INme20CV9BJnhgCLYbtlwnC3xl41Opz8Tzq9Auo/edit#gid=0' ) discord_object.spreadsheet_accessor.open_worksheet(ss, 'Oceania') spreadsheet[ss][ 'Names'] = discord_object.spreadsheet_accessor.get_column_values( ss, 'Oceania', 1, 1, False) spreadsheet[ss][ 'Capitalized'] = discord_object.spreadsheet_accessor.get_column_values( ss, 'Oceania', 2, 1, False) spreadsheet[ss][ 'discordID'] = discord_object.spreadsheet_accessor.get_column_values( ss, 'Oceania', 4, 1, False) spreadsheet[ss][ 'ezname'] = discord_object.spreadsheet_accessor.get_column_values( ss, 'Oceania', 6, 1, False) spreadsheet[ss][ 'eznameUpper'] = discord_object.spreadsheet_accessor.get_column_values( ss, 'Oceania', 7, 1, False) discord_object.locals[COMMAND] = spreadsheet
def cancel(message: Message, discord_object: DiscordBot.DiscordBot): data_message = discord_object.parse_message(message.content) local_id = discord_object.locals['register']['oceaniaGuildActivity'][ 'Oceania']['discordID'] thread_list = [] if message.author.id in local_id: name_id = local_id.index(message.author.id) name = discord_object.locals['register']['oceaniaGuildActivity'][ 'Oceania']['Name'][name_id] if len(data_message) == 3: boss_list = data_message[2] ss = 'oceaniaCarryQueue' cancelled = [] for boss_upper in boss_list: boss = PATCH[boss_upper.lower()] if boss in CRA: ws = 'CRA' else: ws = 'OTHER' boss_queue = discord_object.locals[COMMAND][ss][ws][boss] if name in boss_queue: cancelled.append(NAMES[boss]) index = boss_queue.index(name) discord_object.locals[COMMAND][ss][ws][boss].pop(index) discord_object.locals[COMMAND][ss][ws]['comment_' + boss].pop(index) last_pos = len( discord_object.locals[COMMAND][ss][ws][boss]) new_list = list( filter( None, discord_object.locals[COMMAND][ss][ws][boss] [index:last_pos])) + [''] comment_list = discord_object.locals[COMMAND][ss][ws][ 'comment_' + boss][index:last_pos] + [''] start = (index + 1, INDEX[boss]) end = (last_pos + 1, INDEX[boss]) thread1 = Thread( target=discord_object.spreadsheet_accessor.write_range, args=(ss, ws, start, end, new_list)) thread_list.append(thread1) thread1.start() thread2 = Thread( target=discord_object.spreadsheet_accessor.write_range, args=(ss, ws, (index + 1, INDEX[boss] + 2), (last_pos + 1, INDEX[boss] + 2), comment_list)) thread_list.append(thread2) thread2.start() if len(cancelled) > 0: yield from discord_object.send_message( message.channel, message.author.mention + ' You have cancelled your carry for: {}'.format( ', '.join(cancelled))) else: yield from discord_object.send_message( message.channel, message.author.mention + ' You were not registered for any boss carries.') for thread in thread_list: thread.join()
def default(message, discord_object: DiscordBot.DiscordBot): discord_object.json_data['Commands']['on_join']['User-Defined'] = None discord_object.update_json() yield from discord_object.send_message(message.channel, 'Default message restored')
def main(message, discord_object: DiscordBot.DiscordBot): discord_object.get_json_properties() discord_object.load_commands() yield from discord_object.send_message(message.channel, message.author.mention + ' config.json reparsed.')
def done(message: Message, discord_object: DiscordBot.DiscordBot): data_message = discord_object.parse_message(message.content) thread_pool = [] if len(data_message) == 4: editable = yield from discord_object.send_message( message.channel, message.author.mention + ' Updating carry sheet...') names = data_message[3] boss_list = data_message[2] local_data = discord_object.locals['register']['oceaniaGuildActivity'][ 'Oceania'] real_names = [] not_found = [] last_index = int(discord_object.locals[COMMAND]['oceaniaCarryQueue'] ['CARRYLOG']['length']) + 1 today = '{} {}'.format(discord_object.get_current_day(), discord_object.get_current_time()) for name in names: try: index = local_data['eznameUpper'].index(name.upper()) name = local_data['Name'][index] if name != "": real_names.append(name) else: real_names.append(name) except ValueError: not_found.append(name) carry_index = local_data['discordID'].index(message.author.id) carry_name = local_data['Name'][carry_index] not_in_boss = {} done_bosses = [] for boss_upper in boss_list: try: boss = PATCH[boss_upper.lower()] for name in real_names: index = None if boss in CRA: sheet = 'CRA' else: sheet = 'OTHER' if name in discord_object.locals[COMMAND][ 'oceaniaCarryQueue'][sheet][boss]: index = discord_object.locals[COMMAND][ 'oceaniaCarryQueue'][sheet][boss].index(name) discord_object.locals[COMMAND]['oceaniaCarryQueue'][ sheet][boss].pop(index) else: if boss in not_in_boss.keys(): not_in_boss[boss].append(name) else: not_in_boss[boss] = [name] if NAMES[boss] not in done_bosses: done_bosses.append(NAMES[boss]) new_list = list( filter( None, discord_object.locals[COMMAND]['oceaniaCarryQueue'] [sheet][boss])) + (len(real_names)) * [''] start = (1, INDEX[boss]) end = (len(new_list), INDEX[boss]) thread1 = Thread( target=discord_object.spreadsheet_accessor.write_range, args=('oceaniaCarryQueue', sheet, start, end, new_list)) thread1.start() thread_pool.append(thread1) comment_list = discord_object.locals[COMMAND][ 'oceaniaCarryQueue'][sheet]['comment_' + boss] if index is not None: original_length = len( discord_object.locals[COMMAND]['oceaniaCarryQueue'] [sheet][boss]) comment_list.pop(index) comments = list(comment_list[:original_length] + len(real_names) * ['']) start = (1, INDEX[boss] + 2) end = (len(comments), INDEX[boss] + 2) thread2 = Thread(target=discord_object. spreadsheet_accessor.write_range, args=('oceaniaCarryQueue', sheet, start, end, comments)) thread2.start() thread_pool.append(thread2) writer = list( filter(None, [today, carry_name, NAMES[boss]] + real_names + not_found)) thread3 = Thread( target=discord_object.spreadsheet_accessor.write_range, args=('oceaniaCarryQueue', 'CARRYLOG', (last_index, 1), (last_index, 3 + len(real_names + not_found)), writer)) thread3.start() thread_pool.append(thread3) discord_object.locals[COMMAND]['oceaniaCarryQueue'][ 'CARRYLOG']['length'] += 1 last_index += 1 except KeyError: continue except UnboundLocalError: continue except Exception as e: raise e if len(done_bosses) > 0: msg = ' Done updating carry queue for {}.\n'.format( ', '.join(done_bosses)) if len(not_in_boss) > 0: temp = 'These names also did not appear in the boss list for the following bosses:\n' for boss in not_in_boss.keys(): temp += '{}: {}\n'.format(NAMES[boss], ', '.join(not_in_boss[boss])) msg += temp if len(not_found) > 0: msg += '\nThese names were not recognized:\n{}'.format( ', '.join(not_found)) else: msg = ' The carry queue was updated for no bosses. ' yield from discord_object.edit_message(editable, message.author.mention + msg) for threads in thread_pool: threads.join()
def load_data(discord_object: DiscordBot.DiscordBot, arguments, location): discord_object.locals[COMMAND]['oceaniaGuildActivity'][location[0]][ location[1]] = discord_object.spreadsheet_accessor.get_column_values( arguments[0], arguments[1], arguments[2], arguments[3], arguments[4])
def main(message: Message, discord_object: DiscordBot.DiscordBot): yield from discord_object.send_message( message.channel, 'Type `*help carryme <command>` for a guide on how each command works.\n' 'Available commands:```\nbosses\ncancel\npos```')
def confirmed(message: Message, discord_object: DiscordBot.DiscordBot, editable: Message): ss = 'oceaniaGuildActivity' ws = 'Oceania' message_data = discord_object.parse_message(message.content) name = message_data[1] local_id = discord_object.locals[COMMAND][ss][ws]['discordID'] local_names = discord_object.locals[COMMAND][ss][ws]['Capitalized'] local_ez_names = discord_object.locals[COMMAND][ss][ws]['eznameUpper'] last_pos = discord_object.locals[COMMAND][ss][ws]['lastpos'] if len(message_data) == 2: ezname = replace_special_chars(name) if message.author.id not in local_id and name not in local_names and name not in local_ez_names: if name.upper( ) in discord_object.locals[COMMAND][ss][ws]['Capitalized']: index = discord_object.locals[COMMAND][ss][ws][ 'Capitalized'].index(name.upper()) + 2 start = (index, 4) end = (index, 7) data = [ message.author.id, '', ezname, ezname.upper(), discord_object.get_current_day() ] discord_object.spreadsheet_accessor.write_range( ss, ws, start, end, data) discord_object.locals[COMMAND][ss][ws]['discordID'][ index] = message.author.id discord_object.locals[COMMAND][ss][ws]['ezname'][ index] = ezname discord_object.locals[COMMAND][ss][ws]['eznameUpper'][ index] = ezname.upper() yield from discord_object.edit_message( editable, message.author.mention + ' Registration successful.') elif name.upper( ) in discord_object.locals[COMMAND][ss][ws]['eznameUpper']: index = discord_object.locals[COMMAND][ss][ws][ 'eznameUpper'].index(name.upper()) + 2 start = (index, 1) end = (index, 8) data = [ name, name.upper(), '', message.author.id, '', ezname, ezname.upper(), discord_object.get_current_day() ] discord_object.spreadsheet_accessor.write_range( ss, ws, start, end, data) discord_object.locals[COMMAND][ss][ws]['discordID'][ index] = message.author.id discord_object.locals[COMMAND][ss][ws]['Name'][index] = name discord_object.locals[COMMAND][ss][ws]['Capitalized'][ index] = name.upper() discord_object.locals[COMMAND][ss][ws]['ezname'][ index] = ezname discord_object.locals[COMMAND][ss][ws]['eznameUpper'][ index] = ezname.upper() yield from discord_object.edit_message( editable, message.author.mention + ' Registration successful.') else: start = (last_pos, 1) end = (last_pos, 8) data = [ name, name.upper(), '', message.author.id, '', ezname, ezname.upper(), discord_object.get_current_day() ] discord_object.spreadsheet_accessor.write_range( ss, ws, start, end, data) discord_object.locals[COMMAND][ss][ws]['discordID'].append( message.author.id) discord_object.locals[COMMAND][ss][ws]['Name'].append(name) discord_object.locals[COMMAND][ss][ws]['Capitalized'].append( name.upper()) discord_object.locals[COMMAND][ss][ws]['ezname'].append(ezname) discord_object.locals[COMMAND][ss][ws]['eznameUpper'].append( ezname.upper()) discord_object.locals[COMMAND][ss][ws]['lastpos'] += 1 yield from discord_object.edit_message( editable, message.author.mention + ' Registration successful.')
def main(message, discord_object: DiscordBot.DiscordBot): content = discord_object.parse_message(message.content) if len(content) == 2: if content[1] == '-list': channel_id = message.channel.id index = -1 for x, val in enumerate(discord_object.subreddits): if val[0] == channel_id: index = x break msg = "" if index != -1: msg += " This channel is subscribed to the following subreddits: " for x, subreddit in enumerate( discord_object.subreddits[index][1]): msg += subreddit if x < len(discord_object.subreddits[index][1]) - 1: msg += ", " else: msg += "." else: msg += " This channel is not subscribed to any subreddits." yield from discord_object.send_message( message.channel, message.author.mention + msg) else: channel = message.channel sr = content[1] try: # tests if the subreddit exists discord_object.reddit.subreddit(sr).moderator() channel_is_registered = False for entry in discord_object.subreddits: channel_is_registered = bool(entry[0] == str(channel.id)) if channel_is_registered: break if channel_is_registered: for x, ch in enumerate(discord_object.subreddits): if ch[0] == str(channel.id): if sr not in ch[1]: discord_object.subreddits[x][1].append(sr) discord_object.pool[str(channel.id)].append(sr) add_subreddit(sr, x + 1, discord_object) yield from discord_object.send_message( message.channel, message.author.mention + ' This channel is now subscribed to /r/' + sr + '!') else: yield from discord_object.send_message( message.channel, message.author.mention + ' This channel is already subscribed to /r/' + sr + '.') break else: discord_object.subreddits.append([str(channel.id), [sr]]) add_channel(channel.id, discord_object) add_subreddit(sr, len(discord_object.subreddits), discord_object) discord_object.loop.create_task( discord_object.submission_puller( discord_object.subreddits[-1])) yield from discord_object.send_message( message.channel, message.author.mention + ' This channel is now subscribed to /r/' + sr + '!') except prawcore.exceptions.Redirect: yield from discord_object.send_message( message.channel, message.author.mention + ' That subreddit does not exist.') for thread in thread_pool: thread.join() else: yield from discord_object.send_message( message.channel, message.author.mention + ' Please specify what subreddits to subscribe to.')
def bosses(message: Message, discord_object: DiscordBot.DiscordBot): message_data = discord_object.parse_message(message.content) local_id = discord_object.locals['register']['oceaniaGuildActivity'][ 'Oceania']['discordID'] local_names = discord_object.locals['register']['oceaniaGuildActivity'][ 'Oceania']['Name'] thread_pool = [] if message.author.id in local_id: if len(message_data) == 3: boss_list = message_data[2] username = local_names[local_id.index(str(message.author.id))] ss = 'oceaniaCarryQueue' already_in_list = [] joined = [] for boss_upper in boss_list: if ':' in boss_upper: values = boss_upper.split(':', 1) boss = values[0].lower() comment = values[1] else: boss = boss_upper.lower() comment = '' if boss not in ['hellux', 'hmag']: if boss in CRA: sheet = 'CRA' else: sheet = 'OTHER' if username not in discord_object.locals[COMMAND][ss][ sheet][PATCH[boss]]: row = len(discord_object.locals[COMMAND][ss][sheet][ PATCH[boss]]) + 1 col = INDEX[PATCH[boss]] thread = Thread(target=discord_object. spreadsheet_accessor.write_range, args=( ss, sheet, (row, col), (row, col + 2), [username, '', comment], )) thread_pool.append(thread) thread.start() joined.append(NAMES[PATCH[boss]]) discord_object.locals[COMMAND][ss][sheet][ PATCH[boss]].append(username) else: already_in_list.append(NAMES[PATCH[boss]]) if len(joined) > 0: x = ', '.join(joined) yield from discord_object.send_message( message.channel, message.author.mention + ' You have joined the boss queue for:\n' + x) if len(already_in_list) > 0: y = ', '.join(already_in_list) yield from discord_object.send_message( message.channel, message.author.mention + ' You are already in the boss queue for:\n' + y) else: yield from discord_object.send_message( message.channel, message.author.mention + ' You need to register first! Use *register (MapleIGN) to link your discord ID with your maple IGN.' '\n Warning: You can only register your discord ID to one IGN.') for thread in thread_pool: thread.join()
def main(message, discord_object: DiscordBot.DiscordBot): yield from discord_object.send_message(message.channel, message.author.mention + ' Hi!')
def load_data(discord_object: DiscordBot.DiscordBot, arguments, location): discord_object.locals[COMMAND]['oceaniaCarryQueue'][location[0]][ location[1]] = discord_object.spreadsheet_accessor.get_column_values( arguments[0], arguments[1], arguments[2], filtered=arguments[3])