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

Commit

Permalink
Seventh commit - January 21, 2021 (01R8-210121)
Browse files Browse the repository at this point in the history
  • Loading branch information
tretdm committed Jan 21, 2021
1 parent 2b71a9b commit 38cb73c
Show file tree
Hide file tree
Showing 20 changed files with 513 additions and 200 deletions.
140 changes: 81 additions & 59 deletions discord_bot/bot_d.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions discord_bot/d_commands/calc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
async def calc_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, numexpr):
async def calc_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, numexpr, prefix):
args = message.content.split();
no_args = discord.Embed(title=localization[1][9][0], description=localization[1][9][4], color=botconfig['accent1'])
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)
Expand All @@ -11,6 +11,6 @@ async def calc_cmd(bot, discord, message, botconfig, os, platform, datetime, one
except Exception as e:
result = localization[1][9][3] + str(e)
finally:
calc_content.add_field(name=localization[1][9][2], value="```" + result + "```", inline=False)
calc_content.add_field(name=localization[1][9][2], value="```" + result + "```", inline=False)
calc_content.add_field(name=localization[1][9][6], value=localization[1][9][7], inline=False)
await message.channel.send(embed=calc_content)
12 changes: 6 additions & 6 deletions discord_bot/d_commands/codec.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import base64
import binascii

async def decoder(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, args, binary):
async def decoder(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, args, binary, prefix):
if " ".join(args[2:]) == "" or " ".join(args[2:]) == " " or " ".join(args[2:]) == None:
no_args = discord.Embed(title=localization[1][14][0], description=localization[1][14][8], color=embed_color)
no_args = discord.Embed(title=localization[1][14][0], description=str(localization[1][14][8]).format(prefix), color=embed_color)
return await message.channel.send(embed=no_args)
decoder_content = discord.Embed(title=localization[1][14][0], description=localization[1][14][1] + "\n\n" + localization[1][14][3], color=embed_color)
msg = await message.channel.send(embed=decoder_content)
Expand Down Expand Up @@ -48,9 +48,9 @@ async def on_reaction_add(reaction, user):
decoder_result_content.add_field(name=str(localization[1][14][4]), value='```' + str(result) + '```', inline=True)
await msg.edit(embed=decoder_result_content)

async def encoder(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, args, binary):
async def encoder(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, args, binary, prefix):
if " ".join(args[2:]) == "" or " ".join(args[2:]) == " " or " ".join(args[2:]) == None:
no_args = discord.Embed(title=localization[1][14][0], description=localization[1][14][8], color=embed_color)
no_args = discord.Embed(title=localization[1][14][0], description=str(localization[1][14][8]).format(prefix), color=embed_color)
return await message.channel.send(embed=no_args)
decoder_content = discord.Embed(title=localization[1][14][0], description=localization[1][14][2] + "\n\n" + localization[1][14][3], color=embed_color)
msg = await message.channel.send(embed=decoder_content)
Expand Down Expand Up @@ -109,6 +109,6 @@ async def on_reaction_add(reaction, user):
await msg.edit(content=str('```' + str(result) + '```'), embed=decoder_result_content)
except:
await msg.edit(content='', embed=decoder_result_content)
async def get_help(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color):
help_content = discord.Embed(title=localization[1][14][0], description=localization[1][14][5], color=embed_color)
async def get_help(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, prefix):
help_content = discord.Embed(title=localization[1][14][0], description=str(localization[1][14][5]).format(prefix), color=embed_color)
await message.channel.send(embed=help_content)
6 changes: 3 additions & 3 deletions discord_bot/d_commands/feedback.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
async def feedback_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color):
async def feedback_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, prefix):
args = message.content.split();
no_args = discord.Embed(title=localization[1][10][0], description=localization[1][10][3], color=embed_color)
no_args = discord.Embed(title=localization[1][10][0], description=str(localization[1][10][3]).format(prefix), color=embed_color)
if " ".join(args[1:]) == "" or " ".join(args[1:]) == " " or " ".join(args[1:]) == None:
return await message.channel.send(embed=no_args)
if message.author.id != int(botconfig['owner']):
feedback_content = discord.Embed(title=localization[1][10][0], description=localization[1][10][2], color=embed_color)
feedback_content = discord.Embed(title=localization[1][10][0], description=str(localization[1][10][2]), color=embed_color)
new_message_content = discord.Embed(title='Feedback', description=message.author.name + "#" + str(message.author.discriminator) + ": \"" + " ".join(args[1:]) + "\"", color=embed_color)
new_message_content.add_field(name="Channel ID", value=str(message.channel.id), inline=True)
new_message_content.add_field(name="User ID", value=str(message.author.id), inline=True)
Expand Down
38 changes: 14 additions & 24 deletions discord_bot/d_commands/help.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
import random


async def help_cmd(bot, discord, message, botconfig, platform, os, datetime,
one_result, localization, embed_color):
async def help_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, embed_color, guild_result):
if localization[0] == "Russian":
tips = [
'Для просмотра авторской информационной программы "Новости Тинеликса" достаточно написать команду `tnews`?',
'Все наши ссылки находятся в `info`?',
'Узнать погоду можно в `weather`?',
'Просмотреть рандомные фото можно в `photo`? Вдруг пригодится поставить обои на свой рабочий стол?',
'Что в версии 01R5 (9 января 2020 г.) появилась команда `codec` для зашифровки и расшифровки текста?',
'Зайти на наш саппорт-сервер можно по [ссылке](https://discord.gg/HAt6K2QuJU)'
'Что в версии 01R5 (9 января 2020 г.) появилась команда `codec` для зашифровки и расшифровки текста?'
]
else:
tips = ['All our links on `info` command']
try:
if guild_result[6] == botconfig['prefix']:
custom_prefix = ""
else:
custom_prefix = " `" + guild_result[6] + "`"
except Exception as e:
print(e)
lucky_num = random.randint(0, len(tips) - 1)

help_content = discord.Embed(description=str(botconfig['name'] + localization[1][0][0]).format(
botconfig['prefix'], tips[lucky_num]),
color=embed_color)
help_content.add_field(
name=str(localization[1][0][1][0]),
value=str(localization[1][0][1][1]),
inline=True)
help_content.add_field(
name=str(localization[1][0][2][0]),
value=str(localization[1][0][2][1]),
inline=True)
help_content.add_field(
name=str(localization[1][0][3][0]),
value=str(localization[1][0][3][1]),
inline=True)
help_content.add_field(
name=str(localization[1][0][4][0]),
value=str(localization[1][0][4][1]),
inline=True)
help_content = discord.Embed(description=str(botconfig['name'] + localization[1][0][0]).format(botconfig['prefix'], custom_prefix, tips[lucky_num]),color=embed_color)
help_content.add_field(name=str(localization[1][0][1][0]),value=str(localization[1][0][1][1]),inline=True)
help_content.add_field(name=str(localization[1][0][2][0]),value=str(localization[1][0][2][1]),inline=True)
help_content.add_field(name=str(localization[1][0][3][0]),value=str(localization[1][0][3][1]),inline=True)
help_content.add_field(name=str(localization[1][0][4][0]),value=str(localization[1][0][4][1]),inline=True)
help_content.set_footer(text='Ver. ' + botconfig['version'])
await message.channel.send(embed=help_content)
7 changes: 5 additions & 2 deletions discord_bot/d_commands/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ async def info_cmd(bot, discord, message, botconfig, platform, os, datetime, one
info_content.add_field(name=str(localization[1][15][0]), value=str(localization[1][15][1]), inline=False)
info_content.add_field(name=str(localization[1][15][2]), value=str("Python with discord.py library"), inline=True)
info_content.add_field(name=str(localization[1][15][3]), value="Tinelix (`" + bot.get_user(int(botconfig['owner'])).name + "#" + str(bot.get_user(int(botconfig['owner'])).discriminator) + "`)", inline=True)
info_content.add_field(name=str(localization[1][15][4]), value=str(localization[1][15][5]), inline=True)
info_content.add_field(name=str(localization[1][15][6]), value=str(localization[1][15][7]), inline=True)
if bot.user.id == 785383439196487720:
info_content.add_field(name=str(localization[1][15][4]), value=str(localization[1][15][5]), inline=True)
info_content.add_field(name=str(localization[1][15][6]), value=str(localization[1][15][7]), inline=True)
else:
info_content.add_field(name=str(localization[1][15][6]), value=str(localization[1][15][8]), inline=True)
info_content.set_footer(text="© Tinelix, 2020-2021")
await message.channel.send(embed=info_content)
6 changes: 3 additions & 3 deletions discord_bot/d_commands/photo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import random

async def 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):
async def 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):
args = message.content.split();
try:
if " ".join(args[1:]) == "" or " ".join(args[1:]) == " " or " ".join(args[1:]) == None:
no_args = discord.Embed(title=localization[1][8][0], description=localization[1][8][5], color=embed_color)
no_args = discord.Embed(title=localization[1][8][0], description=str(localization[1][8][5]).format(prefix), color=embed_color)
return await message.channel.send(embed=no_args)
if args[1] == "-u":
if time_diff >= 3600000:
Expand Down Expand Up @@ -75,6 +75,6 @@ async def on_reaction_add(reaction, user):
photo_changed.set_image(url=photo.url)
await msg.edit(embed=photo_changed)
except:
no_args = discord.Embed(title=localization[1][8][0], description=localization[1][8][5], color=embed_color)
no_args = discord.Embed(title=localization[1][8][0], description=str(localization[1][8][5]).format(prefix), color=embed_color)
pass
return await message.channel.send(embed=no_args)
14 changes: 9 additions & 5 deletions discord_bot/d_commands/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def remove_outer_symbols(s):
right = s.rindex("]", left)
return s[:left] + s[left+1:right] + s[right+1:]

async def poll_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, unix_time_millis, embed_color, connection, cursor):
async def poll_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 = ""
Expand Down Expand Up @@ -39,8 +39,12 @@ async def poll_cmd(bot, discord, message, botconfig, platform, os, datetime, one
parameter_option += '-o'
for args_index in args2:
try:
index = args_str.index('[') + 6
rindex = args_str.rindex(']') + 7
if message.content.startswith(botconfig['prefix']):
index = args_str.index('[') + 6
rindex = args_str.rindex(']') + 7
elif message.content.startswith(prefix):
index = args_str.index('[') + 5 + len(prefix)
rindex = args_str.rindex(']') + 6 + len(prefix)
options_str += remove_outer_symbols(args_index[index:rindex])
options = options_str.split("],[")
except:
Expand All @@ -52,7 +56,7 @@ async def poll_cmd(bot, discord, message, botconfig, platform, os, datetime, one
for opt in options:
option_str += emoji_number[str(options.index(opt))] + " " + options[options.index(opt)] + "\n"
if args[1] == "" or args[1] == None or args[2] == "" or parameter_option != '-o' or options == [] or args[2] == None or endtimeerr == "Error":
no_args = discord.Embed(title=localization[1][16][0], description=localization[1][16][4], color=embed_color)
no_args = discord.Embed(title=localization[1][16][0], description=str(localization[1][16][4]).format(prefix), color=embed_color)
return await message.channel.send(embed=no_args)
if endtime == 0:
no_args = discord.Embed(title=localization[1][16][0], description=localization[1][16][5], color=embed_color)
Expand All @@ -69,5 +73,5 @@ async def poll_cmd(bot, discord, message, botconfig, platform, os, datetime, one
await msg.add_reaction(emoji=emoji)
except Exception as e:
print(e)
no_args = discord.Embed(title=localization[1][16][0], description=localization[1][16][4], color=embed_color)
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/post.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
async def post_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, unix_time_millis, embed_color):
async def post_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, unix_time_millis, embed_color, prefix):
args = message.content.split(" ");
guild_community = ""
for guild_features in message.guild.features:
Expand Down
16 changes: 13 additions & 3 deletions discord_bot/d_commands/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ async def get_user(bot, discord, message, botconfig, platform, os, datetime,
inline=False)
except:
pass
if a_user.bot == False:
userprofile_content.add_field(
name=str(localization[1][3][15]),
value="**{0}** ({1}/{2})".format(str(one_result[9]), str(one_result[8]), str(((one_result[9]) * (50 + ((one_result[9]) * 10)) * (one_result[9] + 1)))),
inline=False)
msg = await message.channel.send(embed=userprofile_content)
if str(a_user.avatar_url_as(
format=None, static_format="jpeg", size=4096)) != "" or str(
Expand Down Expand Up @@ -191,6 +196,11 @@ async def on_member_update(before, after):
inline=False)
except:
pass
if a_user.bot == False:
userprofile_changed.add_field(
name=str(localization[1][3][15]),
value="**{0}** ({1}/{2})".format(str(one_result[9]), str(one_result[8]), str(((one_result[9]) * (50 + ((one_result[9]) * 10)) * (one_result[9] + 1)))),
inline=False)
await msg.edit(embed=userprofile_changed)

@bot.event
Expand All @@ -206,7 +216,7 @@ async def on_reaction_add(reaction, user):

async def get_help(bot, discord, message, botconfig, platform, os, datetime,
one_result, localization, args, unix_time_millis,
connection, cursor, embed_color):
connection, cursor, embed_color, prefix):
if one_result[3] < 0:
your_timezone = "-" + str(-round(one_result[3] / 60 / 60 / 1000, 1))
if one_result[3] > 0:
Expand All @@ -219,10 +229,10 @@ async def get_help(bot, discord, message, botconfig, platform, os, datetime,
msgcounter = str(localization[1][5][3])
profilehelp_content = discord.Embed(
title=str(localization[1][5][0]),
description=str(localization[1][5][2]) + msgcounter + ", " + str(
description=str(localization[1][5][2]).format(prefix) + msgcounter + ", " + str(
localization[1][5][4]) + your_timezone + str(localization[1][5][5])
+ ", " + str(localization[1][5][6]) + "\n\n" + str(
localization[1][5][1]),
localization[1][5][1]).format(prefix),
color=embed_color)
await message.channel.send(embed=profilehelp_content)

Expand Down
8 changes: 4 additions & 4 deletions discord_bot/d_commands/reputation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
async def rep_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, embed_color, connection, cursor):
async def rep_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, embed_color, connection, cursor, prefix):
args = message.content.split();
rep_err_b = discord.Embed(title=str(localization[1][17][0]), description=str(localization[1][17][2]), color=embed_color)
no_args = discord.Embed(title=localization[1][17][0], color=embed_color)
no_args.add_field(name=localization[1][17][5], value=localization[1][17][6])
rep_err_b = discord.Embed(title=str(localization[1][17][0]).format(prefix), description=str(localization[1][17][2]), color=embed_color)
no_args = discord.Embed(title=str(localization[1][17][0]).format(prefix), color=embed_color)
no_args.add_field(name=localization[1][17][5], value=str(localization[1][17][6]).format(prefix))
try:
if " ".join(args[1]) == "" or " ".join(args[1]) == " " or " ".join(args[1]) == None or args[1].isdigit() == False:
return await message.channel.send(embed=no_args)
Expand Down
Loading

0 comments on commit 38cb73c

Please sign in to comment.