async def get_result(query, ver, headings, verse_numbers): query = query.replace("|", " ") url = f"https://api.scripture.api.bible/v1/bibles/{versions[ver]}/search" headers = {"api-key": config["apis"]["apibible"]} params = {"query": query, "limit": "1"} async with aiohttp.ClientSession() as session: async with session.get(url, params=params, headers=headers) as resp: if resp is not None: data = await resp.json() data = data["data"]["passages"] text = None if data[0]["bibleId"] != versions[ver]: central.log_message( "err", 0, "apibible", "global", f"{version} is no longer able to be used.") return if len(data) > 0: text = data[0]["content"] if text is None: return soup = BeautifulSoup(text, "lxml") title = "" text = "" for heading in soup.find_all("h3"): title += f"{heading.get_text()} / " heading.decompose() for span in soup.find_all("span", {"class": "v"}): if verse_numbers == "enable": span.replace_with(f"<**{span.get_text()}**> ") else: span.replace_with(" ") span.decompose() for p in soup.find_all("p", {"class": "p"}): text += p.get_text() if headings == "disable": title = "" text = f" {bibleutils.purify_text(text).rstrip()}" verse_object = { "passage": query, "version": version_names[ver], "title": title[0:-3], "text": text } return verse_object
async def heartbeat(self): output = "" for latency_item in self.latencies: shard, latency = latency_item output += f"{shard + 1}: {math.ceil(latency * 100)}ms, " central.log_message("info", 0, "global", "global", output[:-2])
async def on_shard_ready(self, shard_id): shard_count = str(config["BibleBot"]["shards"]) s_id = str(shard_id + 1) status = f"+biblebot {central.version} | Shard {s_id} / {shard_count}" activity = discord.Game(status) await self.change_presence(status=discord.Status.online, activity=activity, shard_id=shard_id) central.log_message("info", shard_id + 1, "global", "global", "shard finished")
async def on_shard_ready(self, shard_id): activity = discord.Game(central.version + " | Shard: " + str(shard_id + 1) + " / " + str(config["BibleBot"]["shards"])) await self.change_presence(status=discord.Status.online, activity=activity, shard_id=shard_id) central.log_message("info", shard_id + 1, "global", "global", "connected")
async def on_shard_ready(self, shard_id): shard_count = str(config["BibleBot"]["shards"]) activity = discord.Game( f"{central.version} | Shard: {str(shard_id + 1)} / {shard_count}") await self.change_presence(status=discord.Status.online, activity=activity, shard_id=shard_id) central.log_message("info", shard_id + 1, "global", "global", "connected")
async def on_ready(self): if int(config["BibleBot"]["shards"]) < 2: status = f"+biblebot {central.version} | Shard: 1 / 1" activity = discord.Game(status) await self.change_presence(status=discord.Status.online, activity=activity) central.log_message("info", 1, "global", "global", "connected") await bot_extensions.send_server_count(self)
async def on_error(self, event, *args, **kwargs): current_time = datetime.now().strftime("%H-%M-%S") file_time = datetime.now().strftime("%Y-%m-%d") central.log_message("err", 0, "global", "global", f"received error in {event}, logging to error_logs/log-{file_time}.txt") output = f"{current_time}\n\n{event}\n\nargs: {args}\n\nkwargs: {kwargs}\n\nex:\n\n{traceback.format_exc()}\n\n---\n\n" pathlib.Path("./error_logs").mkdir(exist_ok=True) output_file = open(f"./error_logs/log-{file_time}.txt", "w") output_file.write(output)
async def send_server_count(bot): dbl_token = central.config["apis"]["topgg"] if dbl_token: headers = {"Authorization": dbl_token} data = {"server_count": len(bot.guilds)} url = f"https://top.gg/api/bots/{bot.user.id}/stats" async with aiohttp.ClientSession() as session: await session.post(url, data=data, headers=headers) central.log_message("info", 0, "global", "global", "Server count sent to top.gg.")
async def run_timed_votds(bot): await bot.wait_until_ready() current_time = datetime.datetime.utcnow().strftime("%H:%M") async with aiotinydb.AIOTinyDB(central.guildDB_path) as guildDB: results = [ x for x in guildDB.all() if "channel" in x and x["time"] == current_time ] count = 0 for item in results: if "channel" in item and "time" in item: channel = bot.get_channel(item["channel"]) try: version = await versions.get_guild_version(channel.guild) lang = await languages.get_guild_language(channel.guild) except AttributeError: version = "RSV" lang = "english" if not version: version = "RSV" if not lang: lang = "english" lang = central.get_raw_language(lang) if channel: reference = await bibleutils.get_votd() result = await utils.get_bible_verse( reference, "embed", version, "enable", "enable") if result: try: await channel.send(lang["votd"]) await channel.send(embed=result["embed"]) except discord.errors.Forbidden: pass count += 1 if count > 0: central.log_message( "info", 0, "votd_sched", "global", f"Sending {str(count)} VOTDs at {current_time}...")
async def on_ready(self): mod_time = os.path.getmtime(dir_path + "/data/BGBookNames/books.json") now = time.time() one_week_ago = now - 60 * 60 * 24 * 7 # seven days to seconds if mod_time < one_week_ago: bg_book_names.get_books() if int(config["BibleBot"]["shards"]) < 2: activity = discord.Game(central.version + " | Shard: 1 / 1") await self.change_presence(status=discord.Status.online, activity=activity) central.log_message("info", 1, "global", "global", "connected")
async def on_ready(self): if int(config["BibleBot"]["shards"]) < 1: status = f"+biblebot {central.version} | Shard: 1 / 1" activity = discord.Game(status) await self.change_presence(status=discord.Status.online, activity=activity) central.log_message("info", 1, "global", "global", "finished") try: self.heartbeat.start() except RuntimeError: pass await bot_extensions.send_server_count(self)
async def run_timed_votds(self): await self.wait_until_ready() while not self.is_closed(): current_time = datetime.datetime.utcnow().strftime("%H:%M") results = [ x for x in central.guildDB.all() if "channel" in x and x["time"] == current_time ] for item in results: if "channel" in item and "time" in item: channel = self.get_channel(item["channel"]) try: version = versions.get_guild_version(channel.guild) lang = languages.get_guild_language(channel.guild) except AttributeError: version = "RSV" lang = "english" if not lang: lang = "english" lang = central.get_raw_language(lang) await channel.send(lang["votd"]) reference = await bibleutils.get_votd() # noinspection PyBroadException try: result = await utils.get_bible_verse( reference, "embed", version, "enable", "enable") await channel.send(embed=result["embed"]) except Exception: traceback.print_exc() pass central.log_message("info", 0, "votd_sched", "global", f"Sending VOTDs at {current_time}...") await asyncio.sleep(60)
def compile_resources(): for file_location in paths: try: temp_file = open(f"{extrabiblical_path}{file_location}").read() except FileNotFoundError: return output = f"{extrabiblical_path}" + file_location.replace( ".raw.json", ".bin") with open(f"{output}", "wb") as fl: temp_out = zlib.compress(bytearray(temp_file, 'utf-8')) fl.write(temp_out) name = file_location.replace(".raw.json", "") if "/" in name: name = name.split("/")[-1] if central: central.log_message("info", 0, "compile_extrabiblical", "global", f"compiled '{name}'") else: print(f"[info] compiled '{name}'")
async def on_message(self, raw): await self.wait_until_ready() sender = raw.author identifier = sender.name + "#" + sender.discriminator channel = raw.channel message = raw.content guild = None if config["BibleBot"]["devMode"] == "True": if str(sender.id) != config["BibleBot"]["owner"]: return if sender == self.user: return if central.is_optout(str(sender.id)): return language = languages.get_language(sender) if hasattr(channel, "guild"): guild = channel.guild if language is None: language = languages.get_guild_language(guild) if hasattr(channel.guild, "name"): source = channel.guild.name + "#" + channel.name else: source = "unknown (direct messages?)" if "Discord Bot" in channel.guild.name: if sender.id != config["BibleBot"]["owner"]: return else: source = "unknown (direct messages?)" if guild is None: shard = 1 else: shard = guild.shard_id + 1 if language is None: language = "english_us" embed_or_reaction_not_allowed = False if guild is not None: try: perms = channel.permissions_for(guild.me) if perms is not None: if not perms.send_messages or not perms.read_messages: return if not perms.embed_links: embed_or_reaction_not_allowed = True if not perms.add_reactions: embed_or_reaction_not_allowed = True if not perms.manage_messages or not perms.read_message_history: embed_or_reaction_not_allowed = True except AttributeError: pass if message.startswith(config["BibleBot"]["commandPrefix"]): command = message[1:].split(" ")[0] args = message.split(" ") if not isinstance(args.pop(0), str): args = None raw_language = getattr(central.languages, language).raw_object cmd_handler = CommandHandler() res = cmd_handler.process_command(bot, command, language, sender, guild, channel, args) original_command = "" self.current_page = 1 if res is None: return if res is not None: if "leave" in res: if res["leave"] == "this": if guild is not None: await guild.leave() else: for item in bot.guilds: if str(item.id) == res["leave"]: await item.leave() await channel.send("Left " + str(item.name)) central.log_message("info", shard, identifier, source, "+leave") return if "isError" not in res: if guild is not None: is_banned, reason = central.is_banned(str(guild.id)) if is_banned: await channel.send( "This server has been banned from using BibleBot. Reason: `" + reason + "`.") await channel.send( "If this is invalid, the server owner may appeal by contacting " + "vypr#0001.") central.log_message("err", shard, identifier, source, "Server is banned.") return is_banned, reason = central.is_banned(str(sender.id)) if is_banned: await channel.send( sender.mention + " You have been banned from using BibleBot. " + "Reason: `" + reason + "`.") await channel.send( "You may appeal by contacting vypr#0001.") central.log_message("err", shard, identifier, source, "User is banned.") return if embed_or_reaction_not_allowed: await channel.send( "I need 'Embed Links', 'Read Message History', " + "'Manage Messages', and 'Add Reactions' permissions!" ) return if "announcement" not in res: if "twoMessages" in res: await channel.send(res["firstMessage"]) await channel.send(res["secondMessage"]) elif "paged" in res: self.total_pages = len(res["pages"]) msg = await channel.send(embed=res["pages"][0]) await msg.add_reaction("⬅") await msg.add_reaction("➡") def check(r, u): if r.message.id == msg.id: if str(r.emoji) == "⬅": if u.id != bot.user.id: if self.current_page != 1: self.current_page -= 1 return True elif str(r.emoji) == "➡": if u.id != bot.user.id: if self.current_page != self.total_pages: self.current_page += 1 return True continue_paging = True try: while continue_paging: reaction, user = await bot.wait_for( 'reaction_add', timeout=120.0, check=check) await reaction.message.edit( embed=res["pages"][self.current_page - 1]) reaction, user = await bot.wait_for( 'reaction_remove', timeout=120.0, check=check) await reaction.message.edit( embed=res["pages"][self.current_page - 1]) except (asyncio.TimeoutError, IndexError): await msg.clear_reactions() else: if "reference" not in res and "text" not in res: # noinspection PyBroadException try: await channel.send(embed=res["message"]) except Exception: pass else: if res["message"] is not None: await channel.send(res["message"]) else: await channel.send("Done.") for original_command_name in raw_language[ "commands"].keys(): untranslated = [ "setlanguage", "userid", "ban", "unban", "reason", "optout", "unoptout", "eval", "jepekula", "joseph", "tiger" ] if raw_language["commands"][ original_command_name] == command: original_command = original_command_name elif command in untranslated: original_command = command else: for original_command_name in raw_language[ "commands"].keys(): if raw_language["commands"][ original_command_name] == command: original_command = original_command_name count = 1 total = len(bot.guilds) for item in bot.guilds: announce_tuple = misc.get_guild_announcements( item, False) # noinspection PyBroadException try: if "Discord Bot" not in item.name: if announce_tuple is not None: chan, setting = announce_tuple else: chan = "preferred" setting = True preferred = [ "misc", "bots", "meta", "hangout", "fellowship", "lounge", "congregation", "general", "bot-spam", "staff" ] if chan != "preferred" and setting: ch = self.get_channel(chan) perm = ch.permissions_for(item.me) if perm.read_messages and perm.send_messages: await channel.send( str(count) + "/" + str(total) + " - " + item.name + " :white_check_mark:") if perm.embed_links: await ch.send( embed=res["message"]) else: await ch.send(res["message"]. fields[0].value) else: await channel.send( str(count) + "/" + str(total) + " - " + item.name + " :regional_indicator_x:") elif chan == "preferred" and setting: sent = False for ch in item.text_channels: try: if not sent: for name in preferred: if ch.name == name: perm = ch.permissions_for( item.me) if perm.read_messages and perm.send_messages: await channel.send( str(count) + "/" + str(total) + " - " + item.name + " :white_check_mark:" ) if perm.embed_links: await ch.send( embed= res["message"] ) else: await ch.send( res["message"] . fields[ 0]. value) else: await channel.send( str(count) + "/" + str(total) + " - " + item.name + " :regional_indicator_x:" ) sent = True except (AttributeError, IndexError): sent = True else: await channel.send( str(count) + "/" + str(total) + " - " + item.name + " :regional_indicator_x:") except Exception: pass count += 1 await channel.send("Done.") clean_args = str(args).replace(",", " ").replace( "[", "").replace("]", "") clean_args = clean_args.replace("\"", "").replace( "'", "").replace(" ", " ") clean_args = clean_args.replace("\n", "").strip() if original_command == "puppet": clean_args = "" elif original_command == "eval": clean_args = "" elif original_command == "announce": clean_args = "" central.log_message( res["level"], shard, identifier, source, "+" + original_command + " " + clean_args) else: # noinspection PyBroadException try: await channel.send(embed=res["return"]) except Exception: pass else: verse_handler = VerseHandler() result = verse_handler.process_raw_message(raw, sender, language, guild) if result is not None: if "invalid" not in result and "spam" not in result: for item in result: try: if "twoMessages" in item: if guild is not None: is_banned, reason = central.is_banned( str(guild.id)) if is_banned: await channel.send( "This server has been banned from using BibleBot. " + "Reason: `" + reason + "`.") await channel.send( "If this is invalid, the server owner may appeal by contacting " + "vypr#0001.") central.log_message( "err", shard, identifier, source, "Server is banned.") return is_banned, reason = central.is_banned( str(sender.id)) if is_banned: await channel.send( sender.mention + " You have been banned from using BibleBot. " + "Reason: `" + reason + "`.") await channel.send( "You may appeal by contacting vypr#0001." ) central.log_message( "err", shard, identifier, source, "User is banned.") return if embed_or_reaction_not_allowed: await channel.send( "I need 'Embed Links', 'Read Message History', " + "'Manage Messages', and 'Add Reactions' permissions!" ) return await channel.send(item["firstMessage"]) await channel.send(item["secondMessage"]) elif "message" in item: if guild is not None: is_banned, reason = central.is_banned( str(guild.id)) if is_banned: await channel.send( "This server has been banned from using BibleBot. " + "Reason: `" + reason + "`.") await channel.send( "If this is invalid, the server owner may appeal by contacting " + "vypr#0001.") central.log_message( "err", shard, identifier, source, "Server is banned.") return is_banned, reason = central.is_banned( str(sender.id)) if is_banned: await channel.send( sender.mention + " You have been banned from using BibleBot. " + "Reason: `" + reason + "`.") await channel.send( "You may appeal by contacting vypr#0001." ) central.log_message( "err", shard, identifier, source, "User is banned.") return if embed_or_reaction_not_allowed: await channel.send( "I need 'Embed Links', 'Read Message History', " + "'Manage Messages', and 'Add Reactions' permissions!" ) return await channel.send(item["message"]) except KeyError: pass if "reference" in item: central.log_message(item["level"], shard, identifier, source, item["reference"]) else: if "spam" in result: await channel.send(result["spam"])
return if embed_or_reaction_not_allowed: await channel.send( "I need 'Embed Links', 'Read Message History', " + "'Manage Messages', and 'Add Reactions' permissions!" ) return await channel.send(item["message"]) except KeyError: pass if "reference" in item: central.log_message(item["level"], shard, identifier, source, item["reference"]) else: if "spam" in result: await channel.send(result["spam"]) if int(config["BibleBot"]["shards"]) > 1: bot = BibleBot(shard_count=int(config["BibleBot"]["shards"])) else: bot = BibleBot() central.log_message("info", 0, "global", "global", central.version + " by Elliott Pardee (vypr)") bot.run(config["BibleBot"]["token"])
async def on_message(self, raw): await self.wait_until_ready() sender = raw.author identifier = sender.name + "#" + sender.discriminator channel = raw.channel message = raw.content guild = None if config["OrthoBot"]["devMode"] == "True": if str(sender.id) != config["OrthoBot"]["owner"]: return if sender == self.user: return if hasattr(channel, "guild"): guild = channel.guild if hasattr(channel.guild, "name"): source = channel.guild.name + "#" + channel.name else: source = "unknown (direct messages?)" if "Discord Bot" in channel.guild.name: if sender.id != config["OrthoBot"]["owner"]: return else: source = "unknown (direct messages?)" if guild is None: shard = 1 else: shard = guild.shard_id + 1 embed_or_reaction_not_allowed = False if guild is not None: try: perms = channel.permissions_for(guild.me) if perms is not None: if not perms.send_messages or not perms.read_messages: return if not perms.embed_links: embed_or_reaction_not_allowed = True if not perms.add_reactions: embed_or_reaction_not_allowed = True if not perms.manage_messages or not perms.read_message_history: embed_or_reaction_not_allowed = True except AttributeError: pass if message.startswith(config["OrthoBot"]["commandPrefix"]): command = message[1:].split(" ")[0] args = message.split(" ") if not isinstance(args.pop(0), str): args = None cmd_handler = CommandHandler() res = cmd_handler.process_command(bot, command, sender, guild, channel, args) self.current_page = 1 if res is None: return if res is not None: if "leave" in res: if res["leave"] == "this": if guild is not None: await guild.leave() else: for item in bot.guilds: if str(item.id) == res["leave"]: await item.leave() await channel.send("Left " + str(item.name)) central.log_message("info", shard, identifier, source, "+leave") return if "isError" not in res: if guild is not None: is_banned, reason = central.is_banned(str(guild.id)) if is_banned: await channel.send("This server has been banned from using OrthoBot. Reason: `" + reason + "`.") await channel.send("If this is invalid, the server owner may appeal by contacting " + "vypr#0001.") central.log_message("err", shard, identifier, source, "Server is banned.") return is_banned, reason = central.is_banned(str(sender.id)) if is_banned: await channel.send(sender.mention + " You have been banned from using OrthoBot. " + "Reason: `" + reason + "`.") await channel.send("You may appeal by contacting vypr#0001.") central.log_message("err", shard, identifier, source, "User is banned.") return if embed_or_reaction_not_allowed: await channel.send("I need 'Embed Links', 'Read Message History', " + "'Manage Messages', and 'Add Reactions' permissions!") return if "twoMessages" in res: await channel.send(res["firstMessage"]) await channel.send(res["secondMessage"]) elif "paged" in res: self.total_pages = len(res["pages"]) msg = await channel.send(embed=res["pages"][0]) await msg.add_reaction("⬅") await msg.add_reaction("➡") def check(r, u): if r.message.id == msg.id: if str(r.emoji) == "⬅": if u.id != bot.user.id: if self.current_page != 1: self.current_page -= 1 return True elif str(r.emoji) == "➡": if u.id != bot.user.id: if self.current_page != self.total_pages: self.current_page += 1 return True continue_paging = True try: while continue_paging: reaction, user = await bot.wait_for('reaction_add', timeout=120.0, check=check) await reaction.message.edit(embed=res["pages"][self.current_page - 1]) reaction, user = await bot.wait_for('reaction_remove', timeout=120.0, check=check) await reaction.message.edit(embed=res["pages"][self.current_page - 1]) except (asyncio.TimeoutError, IndexError): await msg.clear_reactions() else: if "reference" not in res and "text" not in res: await channel.send(embed=res["message"]) else: if res["message"] is not None: await channel.send(res["message"]) else: await channel.send("Done.") clean_args = str(args).replace(",", " ").replace("[", "").replace("]", "") clean_args = clean_args.replace("\"", "").replace("'", "").replace(" ", " ") clean_args = clean_args.replace("\n", "").strip() ignore_arg_commands = ["puppet", "eval"] if command in ignore_arg_commands: clean_args = "" central.log_message(res["level"], shard, identifier, source, config["OrthoBot"]["commandPrefix"] + command + " " + clean_args) else: if "return" in res: await channel.send(embed=res["return"])
async def on_message(self, raw): owner_id = config["BibleBot"]["owner"] await self.wait_until_ready() if ":" not in raw.content: if config["BibleBot"]["commandPrefix"] not in raw.content: return ctx = { "self": bot, "author": raw.author, "identifier": f"{raw.author.id}", "channel": raw.channel, "message": raw.content, "raw": raw, "guild": None, "language": None } is_self = ctx["author"] == self.user is_optout = central.is_optout(str(ctx["author"].id)) if is_self or is_optout: return is_owner = ctx["identifier"] == owner_id if is_owner: ctx["identifier"] = "owner" language = languages.get_language(ctx["author"]) if hasattr(ctx["channel"], "guild"): ctx["guild"] = ctx["channel"].guild if language is None: language = languages.get_guild_language(ctx["guild"]) guild_id = str(ctx["channel"].guild.id) chan_id = str(ctx["channel"].id) source = f"{guild_id}#{chan_id}" if "Discord Bot" in ctx["channel"].guild.name: if not is_owner: return else: source = "unknown (direct messages?)" if ctx["guild"] is None: shard = 1 else: shard = ctx["guild"].shard_id + 1 if language is None or language in ["english_us", "english_uk"]: language = "english" if config["BibleBot"]["devMode"] == "True": # more often than not, new things are added that aren't filtered # through crowdin yet so we do this to avoid having to deal with # missing values language = "default" if not is_owner: return ctx["language"] = central.get_raw_language(language) if ctx["message"].startswith(config["BibleBot"]["commandPrefix"]): command = ctx["message"][1:].split(" ")[0] remainder = " ".join(ctx["message"].split(" ")[1:]) cmd_handler = CommandHandler() res = await cmd_handler.process_command(ctx, command, remainder) original_command = "" if res is None: return if "announcement" in res: central.log_message("info", 0, "owner", "global", "Announcement starting.") await bot_extensions.send_announcement(ctx, res) central.log_message("info", 0, "owner", "global", "Announcement finished.") return if "isError" not in res: if "twoMessages" in res: await ctx["channel"].send(res["firstMessage"]) await ctx["channel"].send(res["secondMessage"]) elif "paged" in res: msg = await ctx["channel"].send(embed=res["pages"][0]) self.current_page[msg.id] = 1 self.total_pages[msg.id] = len(res["pages"]) await msg.add_reaction("⬅") await msg.add_reaction("➡") def check(r, u): if r.message.id == msg.id: if str(r.emoji) == "⬅": if u.id != bot.user.id: if self.current_page[msg.id] != 1: self.current_page[msg.id] -= 1 return True elif str(r.emoji) == "➡": if u.id != bot.user.id: if self.current_page[ msg.id] != self.total_pages[ msg.id]: self.current_page[msg.id] += 1 return True self.continue_paging[msg.id] = True try: while self.continue_paging[msg.id]: reaction, _ = await asyncio.ensure_future( bot.wait_for('reaction_add', timeout=60.0, check=check)) await reaction.message.edit( embed=res["pages"][self.current_page[msg.id] - 1]) reaction, _ = await asyncio.ensure_future( bot.wait_for('reaction_remove', timeout=60.0, check=check)) await reaction.message.edit( embed=res["pages"][self.current_page[msg.id] - 1]) except (asyncio.TimeoutError, IndexError): try: self.current_page.pop(msg.id) self.total_pages.pop(msg.id) self.continue_paging.pop(msg.id) await msg.clear_reactions() except (discord.errors.Forbidden, discord.errors.NotFound): pass elif "embed" in res: try: await ctx["channel"].send(embed=res["embed"]) except discord.errors.Forbidden: await ctx["channel"].send( "Unable to send embed, please verify permissions.") else: if "reference" not in res and "text" not in res: await ctx["channel"].send(embed=res["message"]) else: await ctx["channel"].send(res["message"]) lang = central.get_raw_language(language) for original_command_name in lang["commands"].keys(): untranslated = [ "setlanguage", "userid", "ban", "unban", "reason", "optout", "unoptout", "eval", "jepekula", "joseph", "tiger", "rose", "lsc", "heidelberg", "ccc", "quit" ] if lang["commands"][original_command_name] == command: original_command = original_command_name elif command in untranslated: original_command = command clean_args = remainder.replace("\"", "").replace("'", "").replace( " ", " ") clean_args = clean_args.replace("\n", "").strip() ignore_arg_commands = ["puppet", "eval", "announce"] if original_command in ignore_arg_commands: clean_args = "" central.log_message(res["level"], shard, ctx["identifier"], source, f"+{original_command} {clean_args}") else: await ctx["channel"].send(embed=res["message"]) else: verse_handler = VerseHandler() result = await verse_handler.process_raw_message( raw, ctx["author"], ctx["language"], ctx["guild"]) if result is not None: if "invalid" not in result and "spam" not in result: for item in result: try: if "twoMessages" in item: await ctx["channel"].send(item["firstMessage"]) await ctx["channel"].send(item["secondMessage"] ) elif "message" in item: await ctx["channel"].send(item["message"]) elif "embed" in item: await ctx["channel"].send(embed=item["embed"]) if "reference" in item: central.log_message(item["level"], shard, ctx["identifier"], source, item["reference"]) except (KeyError, TypeError): pass elif "spam" in result: central.log_message("warn", shard, ctx["identifier"], source, "Too many verses at once.") await ctx["channel"].send(result["spam"])
central.log_message(item["level"], shard, ctx["identifier"], source, item["reference"]) except (KeyError, TypeError): pass elif "spam" in result: central.log_message("warn", shard, ctx["identifier"], source, "Too many verses at once.") await ctx["channel"].send(result["spam"]) if int(config["BibleBot"]["shards"]) > 1: bot = BibleBot(shard_count=int(config["BibleBot"]["shards"])) else: bot = BibleBot() if config["BibleBot"]["devMode"] == "True": compile_extrabiblical.compile_resources() asyncio.run(name_scraper.update_books(dry=True)) elif len(sys.argv) == 2 and any([sys.argv[1] == x for x in ["-d", "--dry"]]): asyncio.run(name_scraper.update_books(dry=True)) else: asyncio.run( name_scraper.update_books(apibible_key=config["apis"]["apibible"])) central.log_message("info", 0, "global", "global", f"BibleBot {central.version} by Elliott Pardee (vypr)") bot_extensions.run_timed_votds.start(bot) bot.run(config["BibleBot"]["token"])
async def on_disconnect(self): central.log_message("info", 0, "global", "global", "shard disconnected")
async def on_ready(self): if int(config["OrthoBot"]["shards"]) < 2: activity = discord.Game(central.version + " | Shard: 1 / 1") await self.change_presence(status=discord.Status.online, activity=activity) central.log_message("info", 1, "global", "global", "connected")