diff --git a/discord_bot/bot_d.py b/discord_bot/bot_d.py index 2b77095..b966bf4 100644 --- a/discord_bot/bot_d.py +++ b/discord_bot/bot_d.py @@ -429,7 +429,7 @@ async def on_message(message): if message.content.startswith(botconfig['prefix'] + 'photo') or message.content.startswith(guild_result[6] + 'photo'): await photo_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, unix_time_millis, unsplash, time_diff, bot_data_result, cursor, connection, embed_color, reddit, prefix) if message.content.startswith(botconfig['prefix'] + 'calc') or message.content.startswith(guild_result[6] + 'calc'): - await calc_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, numexpr, prefix) + await calc_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, numexpr, prefix, embed_color) if message.content.startswith(botconfig['prefix'] + 'feedback') or message.content.startswith(guild_result[6] + 'feedback'): await feedback_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, prefix) if message.content.startswith(botconfig['prefix'] + 'weather') or message.content.startswith(guild_result[6] + 'weather'): diff --git a/discord_bot/d_author_cmds/tnews.py b/discord_bot/d_author_cmds/tnews.py new file mode 100644 index 0000000..1f8414f --- /dev/null +++ b/discord_bot/d_author_cmds/tnews.py @@ -0,0 +1,36 @@ +from .tnews_list import tnews_list +async def get_tnews(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, args, unix_time_millis, connection, cursor, embed_color): + news_title = "" + news_text = "" + tnews_content = discord.Embed(title=localization[1][6][0], description=localization[1][6][1] + tnews_list['title']['one'] + "\n" + tnews_list['title']['two'], color=embed_color) + tnews_content.set_footer(text=tnews_list['footer']) + msg = await message.channel.send(embed=tnews_content) + await msg.add_reaction(emoji="1⃣") + await msg.add_reaction(emoji="2⃣") + @bot.event + async def on_reaction_add(reaction, user): + channel = reaction.message.channel + if reaction.emoji == "1⃣" and user.id != bot.user.id: + news_title = tnews_list['title']['non-unicode']['one'] + news_text = tnews_list['news']['one'] + tnews_text_content = discord.Embed(title=news_title, description=news_text, color=embed_color) + tnews_text_content.set_image(url=tnews_list['images']['one']) + await msg.edit(embed=tnews_text_content) + if reaction.emoji == "2⃣" and user.id != bot.user.id: + news_title = tnews_list['title']['non-unicode']['two'] + news_text = tnews_list['news']['two'] + tnews_text_content = discord.Embed(title=news_title, description=news_text, color=embed_color) + tnews_text_content.set_image(url=tnews_list['images']['two']) + await msg.edit(embed=tnews_text_content) + if reaction.emoji == "3⃣" and user.id != bot.user.id: + news_title = tnews_list['title']['non-unicode']['three'] + news_text = tnews_list['news']['three'] + tnews_text_content = discord.Embed(title=news_title, description=news_text, color=embed_color) + tnews_text_content.set_image(url=tnews_list['images']['three']) + await msg.edit(embed=tnews_text_content) + if reaction.emoji == "4️⃣" and user.id != bot.user.id: + news_title = tnews_list['title']['non-unicode']['four'] + news_text = tnews_list['news']['four'] + tnews_text_content = discord.Embed(title=news_title, description=news_text, color=embed_color) + tnews_text_content.set_image(url=tnews_list['images']['four']) + await msg.edit(embed=tnews_text_content) diff --git a/discord_bot/d_author_cmds/tnews_list.py b/discord_bot/d_author_cmds/tnews_list.py new file mode 100644 index 0000000..937b4a4 --- /dev/null +++ b/discord_bot/d_author_cmds/tnews_list.py @@ -0,0 +1,21 @@ +tnews_list = { + 'title': { + 'non-unicode': { + 'one': 'Релиз Vision 01R5 (8 января 2021 г.)', + 'two': 'Бот теперь доступен в одном из мониторингов', + 'three': 'Падение сервисов Google и его последствия', + 'four': 'Чем отличается бот Vision от фейков (или клонов)?' + }, + 'one': '1⃣ Скоро новый релиз - VisionOne 01R8 (21 января 2021 г.)', + 'two': '2⃣ Наш саппорт-сервер VisionOne уже открыт!', + }, + 'news': { + 'one': 'Скоро будет размещен новый релиз бота VisionOne - 01R8, сегодня или завтра, пока все будет полностью протестировано.\n\n**Изменения**:\n1. Будет добавлена ручная смена префикса бота.\n2. Будет добавлена глобальная система уровней\n3. Станет возможным задавать свои приветственные и прощальные сообзения для Вашего сервера.', + 'two': 'Перейти можно по нашей ссылке в `=info`.', + }, + 'images': { + 'one': '', + 'two': 'https://cdn.discordapp.com/attachments/787270057952542720/797275961337839716/Screenshot_2021-01-09-08-29-34.png', + }, + 'footer': 'Актуально на 21 января 2020 г.' +} diff --git a/discord_bot/d_commands/calc.py b/discord_bot/d_commands/calc.py index 6189a7c..97e8b7b 100644 --- a/discord_bot/d_commands/calc.py +++ b/discord_bot/d_commands/calc.py @@ -1,10 +1,10 @@ -async def calc_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, numexpr, prefix): +async def calc_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, numexpr, prefix, embed_color): args = message.content.split(); no_args = discord.Embed(title=localization[1][9][0], description=str(localization[1][9][4]).format(prefix), color=botconfig['accent1']) no_args.add_field(name=localization[1][9][6], value=localization[1][9][7], inline=False) if " ".join(args[1:]) == "" or " ".join(args[1:]) == " " or " ".join(args[1:]) == None: return await message.channel.send(embed=no_args) - calc_content = discord.Embed(title=localization[1][9][0], color=botconfig['accent1']) + calc_content = discord.Embed(title=localization[1][9][0], color=embed_color) calc_content.add_field(name=localization[1][9][1], value="```py\n" + " ".join(args[1:]) + "```", inline=False) try: result = str(numexpr.evaluate(" ".join(args[1:]))) diff --git a/discord_bot/d_commands/profile.py b/discord_bot/d_commands/profile.py index e360871..d2d9d30 100644 --- a/discord_bot/d_commands/profile.py +++ b/discord_bot/d_commands/profile.py @@ -12,7 +12,18 @@ async def get_user(bot, discord, message, botconfig, platform, os, datetime, if one_result[3] == 0: your_timezone = "" try: - a_user = await message.guild.fetch_member(subargs) + search_results = 0 + ids = [] + member_name_lower = "" + if " ".join(args[2:]).isdigit() == True: + a_user = await message.guild.fetch_member(subargs) + else: + for member in message.guild.members: + member_name_lower = member.name.lower() + if member_name_lower.startswith(" ".join(args[2:]).lower()) or member.name.startswith(" ".join(args[2:])): + search_results = 1 + ids.append(member.id) + a_user = await message.guild.fetch_member(ids[0]) except: a_user = message.author try: diff --git a/discord_bot/d_events/new_level.py b/discord_bot/d_events/new_level.py index f407e02..89daca8 100644 --- a/discord_bot/d_events/new_level.py +++ b/discord_bot/d_events/new_level.py @@ -13,7 +13,7 @@ async def message_to_xp(bot, discord, message, botconfig, platform, os, datetime lv=math.floor(lvch) print(((one_result[9]) * (50 + ((one_result[9]) * 10))) * (one_result[9] + 1)) if one_result[9] < lv: - if message.content.startswith(botconfig['prefix']) is False or message.content.startswith(guild_result[6]) is False: + if message.content.startswith(botconfig['prefix']) is False and message.content.startswith(guild_result[6]) is False and one_result[9] > 0: new_level_msg = discord.Embed(title=localization[1][18][0], description=str(localization[1][18][1]).format('<@' + str(message.author.id) + '>', lv), color=embed_color) await message.channel.send(embed=new_level_msg) cursor.executemany('UPDATE users SET level=? where userid=?', [(lv, message.author.id)]) diff --git a/discord_bot/discord_botconfig.py b/discord_bot/discord_botconfig.py index 114b523..3fd3f29 100644 --- a/discord_bot/discord_botconfig.py +++ b/discord_bot/discord_botconfig.py @@ -12,7 +12,7 @@ 'accent1': 0xd7832a, 'accent2': 0xcb3532, 'accent3': 0x6eda5f, - 'version': '01R8-210121', + 'version': '01R8-210123', 'owner': '741883312108339231', 'logs_channel': 788723868255649832, 'unsplash_ak': os.environ['UNSAKEY'],