Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Commit

Permalink
10th commit - February 23, 2021 (01R9-210223)
Browse files Browse the repository at this point in the history
  • Loading branch information
tretdm authored Feb 23, 2021
1 parent 0ef46a4 commit 9a4ee8d
Show file tree
Hide file tree
Showing 19 changed files with 842 additions and 136 deletions.
173 changes: 124 additions & 49 deletions discord_bot/bot_d.py

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions discord_bot/d_commands/calc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
async def calc_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, numexpr, prefix, embed_color):
args = message.content.split();
args = message.content.split();
err = ""
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:
Expand All @@ -8,7 +9,14 @@ async def calc_cmd(bot, discord, message, botconfig, os, platform, datetime, one
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:])))
except Exception as e:
except Exception as e:
if str(e) == 'division by zero':
result = localization[1][9][8]
elif str(e) == "Python int too large to convert to C long":
result = localization[1][9][9]
elif str(e).startswith("'VariableNode' object has no attribute"):
result = localization[1][9][10]
else:
result = localization[1][9][3] + str(e)
finally:
calc_content.add_field(name=localization[1][9][2], value="```" + result + "```", inline=False)
Expand Down
2 changes: 1 addition & 1 deletion discord_bot/d_commands/db.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
async def db_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, connection, cursor):
args = message.content.split();
subargs = args[1:]
accessdenied_msg = discord.Embed(title="Доступ запрещен", description="Эта команда защищена владельцем бота, поэтому она недоступна.", color=botconfig['accent2'])
accessdenied_msg = discord.Embed(description=localization[1][19][0], color=botconfig['accent2'])
eval_content = discord.Embed(title="Просмотр базы данных", color=botconfig['accent1'])
if str(message.author.id) != botconfig['owner']:
return await message.channel.send(embed=accessdenied_msg)
Expand Down
51 changes: 51 additions & 0 deletions discord_bot/d_commands/embed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
def remove_outer_symbols(s):
left = s.index("[")
right = s.rindex("]", left)
return s[:left] + s[left+1:right] + s[right+1:]

async def embed_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, unix_time_millis, embed_color, connection, cursor, prefix):
args = message.content.split(" ");
args2 = message.content.split("-[]");
parameter_option = ""
args_str = " ".join(args[1:])
try:
question_rindex = args_str.rindex('-t', 0)
text = args_str[:question_rindex]
options_str = ""
options = []
endtimeerr = ""
endtime = 0
for args_index in args:
if args_index == "-t":
parameter_option += '-t'
for args_index in args2:
try:
if message.content.startswith(botconfig['prefix']):
index = args_str.index('[') + 7
rindex = args_str.rindex(']') + 8
elif message.content.startswith(prefix):
index = args_str.index('[') + 6 + len(prefix)
rindex = args_str.rindex(']') + 7 + len(prefix)
options_str += remove_outer_symbols(args_index[index:rindex])
options = options_str.split("],[")
except:
pass

embed_title = ""
embed_footer = ""
for opt in options:
if options.index(opt) == 0:
embed_title = opt
print('Yes! ' + embed_title+ "\n" + str(options))
if options.index(opt) == 1:
embed_footer += opt
if args[1] == "" or args[1] == None or args[2] == "" or parameter_option != '-t' or options == [] or args[2] == None:
no_args = discord.Embed(title=localization[1][20][0], description=str(localization[1][20][1]).format(prefix), color=embed_color)
return await message.channel.send(embed=no_args)
embed = discord.Embed(title=embed_title, description=text, color=embed_color)
embed.set_footer(text=embed_footer)
msg = await message.channel.send(embed=embed)
except Exception as e:
print(e)
no_args = discord.Embed(title=localization[1][16][0], description=str(localization[1][16][4]).format(prefix), color=embed_color)
await message.channel.send(embed=no_args)
2 changes: 1 addition & 1 deletion discord_bot/d_commands/eval.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
async def eval_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, en_US, guild_result, intents, embed_color):
args = message.content.split();
accessdenied_msg = discord.Embed(title="Доступ запрещен", description="Эта команда защищена владельцем бота, поэтому она недоступна.", color=botconfig['accent2'])
accessdenied_msg = discord.Embed(description=localization[1][19][0], color=botconfig['accent2'])
eval_content = discord.Embed(title="Определение качества кода", color=botconfig['accent1'])
eval_content.add_field(name="Листинг", value="```py\n" + " ".join(args[1:]) + "```", inline=False)
if str(message.author.id) != botconfig['owner']:
Expand Down
6 changes: 5 additions & 1 deletion discord_bot/d_commands/guilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ async def guilds_cmd(bot, discord, message, botconfig, os, platform, datetime, o
try:
guild_list = ""
for bot_guild in bot.guilds:
guild_list += str(bot.guilds.index(bot_guild) + 1) + ". " + str(bot_guild.name) + " | Members: " + str(bot_guild.member_count) + "\n"
bots_count = 0
for member in bot_guild.members:
if member.bot == True:
bots_count += 1
guild_list += str(bot.guilds.index(bot_guild) + 1) + ". " + str(bot_guild.id) + "\nMembers: " + str(bot_guild.member_count) + " | Bots: " + str(bots_count) + "\n"
except Exception as e:
guild_list = "Обнаружено исключение!\n" + str(e)
finally:
Expand Down
9 changes: 6 additions & 3 deletions discord_bot/d_commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
async def help_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, embed_color, guild_result):
if localization[0] == "Russian":
tips = [
'Для просмотра авторской информационной программы "Новости Тинеликса" достаточно написать команду `tnews`?',
'С помощью VisionOne можно проводить голосования?',
'Все наши ссылки находятся в `info`?',
'Узнать погоду можно в `weather`?',
'Просмотреть рандомные фото можно в `photo`? Вдруг пригодится поставить обои на свой рабочий стол?',
'Начиная с версии VisionOne 01R8 (21 января 2021 г.), стало возможным менять префиксы, получать опыты за сообщения и т.д?',
'Поступили две новости в `=tnews`?',
'Игра "Магический шар" генерирует случайные ответы трех типов (да/нет/хз) для заданного вопроса? Обратите внимание, что совпадения случайны, поэтому воспринимайте как игру, а не как реальность.',
'Автор {0} (`{1}`) начал строить своего предшественника под названием Highflash в декабре 2018 г. на discord.js (JavaScript).'.format(botconfig['name'], bot.get_user(int(botconfig['owner'])).name + "#" + str(bot.get_user(int(botconfig['owner'])).discriminator))
'Автор {0} (`{1}`) начал строить своего предшественника под названием Highflash в декабре 2018 г. на discord.js (JavaScript).'.format(botconfig['name'], bot.get_user(int(botconfig['owner'])).name + "#" + str(bot.get_user(int(botconfig['owner'])).discriminator)),
'Можно послушать музыку в `=music`? В этой команде присутствует поддержка плейлиста, но такая своеобразная.'
]
else:
tips = [
Expand All @@ -23,6 +24,8 @@ async def help_cmd(bot, discord, message, botconfig, platform, os, datetime, one
custom_prefix = ""
else:
custom_prefix = " `" + guild_result[6] + "`"
if custom_prefix == None:
custom_prefix = "="
except Exception as e:
print(e)
lucky_num = random.randint(0, len(tips) - 1)
Expand Down
Loading

0 comments on commit 9a4ee8d

Please sign in to comment.