From 0263c0428ab390ae45fb1655755eafa7f9990345 Mon Sep 17 00:00:00 2001 From: Dmitry Tretyakov <76806170+tretdm@users.noreply.github.com> Date: Wed, 13 Jan 2021 18:12:12 +0700 Subject: [PATCH] Fifth commit - January 13, 2021 (01R7-210113) --- discord_bot/bot_d.py | 110 ++++-- discord_bot/d_commands/codec.py | 114 ++++++ discord_bot/d_commands/eval.py | 5 +- discord_bot/d_commands/guilds.py | 12 + discord_bot/d_commands/help.py | 46 ++- discord_bot/d_commands/info.py | 9 + discord_bot/d_commands/poll.py | 73 ++++ discord_bot/d_commands/post.py | 2 +- discord_bot/d_commands/profile.py | 521 +++++++++++++++++---------- discord_bot/d_commands/reputation.py | 75 ++++ discord_bot/d_commands/set.py | 36 +- discord_bot/d_commands/state.py | 1 - discord_bot/d_events/logging.py | 8 +- discord_bot/d_languages/binary.py | 165 +++++++++ discord_bot/d_languages/en_US.py | 59 ++- discord_bot/d_languages/ru_RU.py | 62 +++- discord_bot/discord_botconfig.py | 4 +- main.py | 2 - 18 files changed, 1023 insertions(+), 281 deletions(-) create mode 100644 discord_bot/d_commands/codec.py create mode 100644 discord_bot/d_commands/guilds.py create mode 100644 discord_bot/d_commands/info.py create mode 100644 discord_bot/d_commands/poll.py create mode 100644 discord_bot/d_commands/reputation.py create mode 100644 discord_bot/d_languages/binary.py diff --git a/discord_bot/bot_d.py b/discord_bot/bot_d.py index ff001d5..72ee92f 100644 --- a/discord_bot/bot_d.py +++ b/discord_bot/bot_d.py @@ -8,13 +8,16 @@ import sys import traceback import json +import numexpr +import gc +import keep_alive +keep_alive.keep_alive() +from requests.auth import HTTPBasicAuth from threading import Timer from sqlite3 import Error from discord.ext import commands from .discord_botconfig import botconfig -import keep_alive -import numexpr from unsplash.api import Api as unsplash_api from unsplash.auth import Auth @@ -29,6 +32,10 @@ from .d_commands.weather import weather_cmd from .d_commands.crystball import crystball_cmd from .d_commands.post import post_cmd +from .d_commands.guilds import guilds_cmd +from .d_commands.info import info_cmd +from .d_commands.poll import poll_cmd +from .d_commands.reputation import rep_cmd import discord_bot.d_commands.set as settings import discord_bot.d_commands.profile as profile import discord_bot.d_events.cooldown as cooldown @@ -36,6 +43,8 @@ import discord_bot.d_author_cmds.tnews as tnews import discord_bot.d_commands.blacklist as blacklist import discord_bot.d_events.new_member as autorole +import discord_bot.d_commands.codec as codec +import discord_bot.mem import praw reddit = praw.Reddit(client_id=os.environ['REDDITID'], @@ -43,6 +52,7 @@ user_agent='Vision Bot', username='dmitcomputers') +import discord_bot.d_languages.binary as binary import discord_bot.d_languages.en_US as en_US import discord_bot.d_languages.ru_RU as ru_RU @@ -83,7 +93,10 @@ def create_connection(path): timezone INT NOT NULL, dbregdate INT NOT NULL, messagecount TEXT NOT NULL, - lastmsgtime INT NOT NULL); + lastmsgtime INT NOT NULL, + reputation INT NOT NULL, + scores INT NOT NULL, + level INT NOT NULL); """) cursor.execute("""CREATE TABLE IF NOT EXISTS guilds( guildid TEXT NOT NULL PRIMARY KEY, @@ -106,36 +119,60 @@ def create_connection(path): number INT NOT NULL PRIMARY KEY, unsplash_count INT NOT NULL); """) +cursor.execute("""CREATE TABLE IF NOT EXISTS polls( + msgid INT NOT NULL PRIMARY KEY, + userid INT NOT NULL, + enddate INT NOT NULL); + """) +cursor.execute("""CREATE TABLE IF NOT EXISTS reputations( + msgid INT NOT NULL PRIMARY KEY, + userid INT NOT NULL, + repid INT NOT NULL, + fan TEXT NOT NULL, + hater TEXT NOT NULL); + """) connection.commit() + @bot.event async def on_ready(): - keep_alive.keep_alive() print('\nWelcome! Vision ver. ' + botconfig['version'] + '\n(©) 2020-2021 Tinelix. All rights reserved.') print('\nConnected - ' + bot.user.name + '#' + bot.user.discriminator + '\nLatency: ' + str(round(bot.latency * 1000, 2)) + ' ms | Guilds: ' + str(len(bot.guilds))) print('----------------------------------------------------------------------') + boticord_token = os.environ['BOTICORDTOKEN'] + bots_ds_token = os.environ['BOTSDST'] game = discord.Game(str(len(bot.guilds)) + " guilds | =help", type=discord.ActivityType.watching) await bot.change_presence(status=discord.Status.dnd, activity=game) - res = requests.post("https://api.server-discord.com/v2/bots/785383439196487720/stats", params={'id': 785383439196487720}, headers={'Authorization': os.environ['BOTSDST']}, data={'shards': 0, 'servers': len(bot.guilds)}) - print(res) + res = requests.post("https://api.server-discord.com/v2/bots/785383439196487720/stats", headers={'Content-Type':'application/json', + 'Authorization': 'SDC {0}'.format(bots_ds_token)}, json={'shards': 0, 'servers': len(bot.guilds)}) + print(res.content.decode('utf-8')) + res2 = requests.post("https://boticord.top/api/stats", headers={'Content-Type':'application/json', + 'Authorization': '{}'.format(boticord_token)}, json={'shards': 0, 'servers': len(bot.guilds), 'users': len(bot.users)}) + print(res2.content.decode('utf-8')) @bot.event async def on_guild_join(guild): - requests.post("https://api.server-discord.com/v2/bots/785383439196487720/stats", params={'id': 785383439196487720}, headers={'Authorization': os.environ['BOTSDST']}, data={'shards': 0, 'servers': len(bot.guilds)}) + boticord_token = os.environ['BOTICORDTOKEN'] + bots_ds_token = os.environ['BOTSDST'] + res = requests.post("https://api.server-discord.com/v2/bots/785383439196487720/stats", headers={'Content-Type':'application/json', + 'Authorization': 'SDC {0}'.format(bots_ds_token)}, json={'shards': 0, 'servers': len(bot.guilds)}) + print(res.content.decode('utf-8')) + res2 = requests.post("https://boticord.top/api/stats", headers={'Content-Type':'application/json', + 'Authorization': '{}'.format(boticord_token)}, json={'shards': 0, 'servers': len(bot.guilds), 'users': len(bot.users)}) game = discord.Game(str(len(bot.guilds)) + " guilds | =help", type=discord.ActivityType.watching) await bot.change_presence(status=discord.Status.dnd, activity=game) - try: - cursor.execute("SELECT * FROM blacklist_guilds WHERE guildid='" + str(guild.id) + "';") - blacklist_guild_result = cursor.fetchone() - print("SQLite Database | " + str(blacklist_guild_result)) - await bot.get_guild(int(blacklist_guild_result[0])).leave() - except Exception as e: - print(e) guild_s = [(guild.id, str(guild.region), 0, unix_time_millis(datetime.datetime.now()), "Enabled", 'Standart', '=', 'English', 0, '', 0, '')] cursor.executemany("INSERT OR REPLACE INTO guilds VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", guild_s) # print(guild) connection.commit() await logging.joining_logger(bot, discord, guild, connection, cursor, unix_time_millis, botconfig) + +@bot.event +async def on_guild_remove(guild): + requests.post("https://api.server-discord.com/v2/bots/785383439196487720/stats", params={'id': 785383439196487720}, headers={'Authorization': os.environ['BOTSDST']}, data={'shards': 0, 'servers': len(bot.guilds)}) + game = discord.Game(str(len(bot.guilds)) + " guilds | =help", type=discord.ActivityType.watching) + await bot.change_presence(status=discord.Status.dnd, activity=game) + await logging.leaving_logger(bot, discord, guild, connection, cursor, unix_time_millis, botconfig) @bot.event async def on_member_join(member): @@ -170,7 +207,7 @@ async def on_message(message): elif one_result[1] == "English": localization = en_US.get() if one_result[5] == "Enabled": - user = [(message.author.id, one_result[1], one_result[2] + 1, one_result[3], one_result[4], "Enabled", unix_time_millis(message.created_at))] + user = [(message.author.id, one_result[1], one_result[2] + 1, one_result[3], one_result[4], "Enabled", unix_time_millis(message.created_at), one_result[7], one_result[8], one_result[9])] userdata_recovery = { "userid": message.author.id, "botlanguage": one_result[1], @@ -178,10 +215,11 @@ async def on_message(message): "timezone": one_result[3], "dbregdate": one_result[4], "messagecount": "Enabled", - "lastmsgtime": unix_time_millis(message.created_at) + "lastmsgtime": unix_time_millis(message.created_at), + "reputation": one_result[7] } elif one_result[5] == "Disabled": - user = [(message.author.id, one_result[1], one_result[2], one_result[3], one_result[4], "Disabled", unix_time_millis(message.created_at))] + user = [(message.author.id, one_result[1], one_result[2], one_result[3], one_result[4], "Disabled", unix_time_millis(message.created_at), one_result[7], one_result[8], one_result[9])] userdata_recovery = { "userid": message.author.id, "botlanguage": one_result[1], @@ -189,7 +227,8 @@ async def on_message(message): "timezone": one_result[3], "dbregdate": one_result[4], "messagecount": "Disabled", - "lastmsgtime": unix_time_millis(message.created_at) + "lastmsgtime": unix_time_millis(message.created_at), + "reputation": one_result[7] } else: user = [(message.author.id, one_result[1], one_result[2] + 1, one_result[3], one_result[4], one_result[5], unix_time_millis(message.created_at))] @@ -200,7 +239,8 @@ async def on_message(message): "timezone": one_result[3], "dbregdate": one_result[4], "messagecount": one_result[5], - "lastmsgtime": unix_time_millis(message.created_at) + "lastmsgtime": unix_time_millis(message.created_at), + "reputation": one_result[7] } if guild_result[4] == "Enabled": guild = [(message.guild.id, guild_result[1], guild_result[2] + 1, guild_result[3], "Enabled", guild_result[5], guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])] @@ -219,7 +259,7 @@ async def on_message(message): "goodbyetext": guild_result[11], }, elif guild_result[4] == "Disabled": - guild = [(message.guild.id, guild_result[1], guild_result[2] + 1, guild_result[3], "Disabled", guild_result[5], guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])] + guild = [(message.guild.id, guild_result[1], guild_result[2], guild_result[3], "Disabled", guild_result[5], guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])] guilddata_recovery = { "guildid": message.guild.id, "region": guild_result[1], @@ -276,15 +316,15 @@ async def on_message(message): print("Registration...") pass if str(message.guild.region) == "russia": - user = [(message.author.id, "Russian", 0, 10800000, unix_time_millis(message.created_at), "Disabled", unix_time_millis(message.created_at))] + user = [(message.author.id, "Russian", 0, 10800000, unix_time_millis(message.created_at), "Disabled", unix_time_millis(message.created_at), 0, 0, 0)] guild = [(message.guild.id, str(message.guild.region), 0, unix_time_millis(message.created_at), "Disabled", "Standart", "=", "Russian", 0, "", 0, "")] else: - user = [(message.author.id, "English", 0, 10800000, unix_time_millis(message.created_at), "Disabled", unix_time_millis(message.created_at))] + user = [(message.author.id, "English", 0, 10800000, unix_time_millis(message.created_at), "Disabled", unix_time_millis(message.created_at), 0, 0, 0)] guild = [(message.guild.id, str(message.guild.region), 0, unix_time_millis(message.created_at), "Disabled", "Standart", "=", "English", 0, "", 0, "")] print(e) bot_data = [(0, 0)] - cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?);", user) + cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", user) # print(user) connection.commit() cursor.executemany("INSERT OR REPLACE INTO guilds VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", guild) @@ -310,6 +350,8 @@ async def on_message(message): await state_cmd(bot, discord, sqlite3, message, botconfig, os, platform, datetime, one_result, localization, embed_color, connection, cursor) if message.content.startswith(botconfig['prefix'] + 'eval'): await eval_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, en_US, guild_result, intents, embed_color) + if message.content.startswith(botconfig['prefix'] + 'guilds'): + await guilds_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, guild_result, intents, embed_color) if message.content.startswith(botconfig['prefix'] + 'db'): await db_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, connection, cursor) if message.content.startswith(botconfig['prefix'] + 'clock'): @@ -368,22 +410,38 @@ async def on_message(message): await crystball_cmd(bot, discord, sqlite3, message, botconfig, os, platform, datetime, one_result, localization, embed_color, requests) if message.content.startswith(botconfig['prefix'] + 'post'): await post_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, unix_time_millis, embed_color) + if message.content.startswith(botconfig['prefix'] + 'info'): + await info_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, embed_color) if message.content.startswith(botconfig['prefix'] + 'codec'): - args = message.content.split(); + args = message.content.split(); + try: if args[1] == "-d": - return + await codec.decoder(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, args, binary) + if args[1] == "-e": + await codec.encoder(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, args, binary) + except Exception as e: + await codec.get_help(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color) + print(e) + if message.content.startswith(botconfig['prefix'] + 'poll'): + await poll_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, unix_time_millis, embed_color, connection, cursor) + if message.content.startswith(botconfig['prefix'] + 'rep'): + await rep_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, embed_color, connection, cursor) except Exception as e: if message.content.startswith(botconfig['prefix']): exc_type, exc_value, exc_tb = sys.exc_info() ex = traceback.format_exception(exc_type, exc_value, exc_tb) await logging.traceback_logger(bot, discord, message, one_result, guild_result, connection, cursor, unix_time_millis, botconfig, bot_data_result, ex, e) if str(e) == "local variable 'localization' referenced before assignment": - dbregistred_content = discord.Embed(title="База данных пользователя", description="База данных пользователя зарегистрирована, пишите команду еще раз.", color=botconfig['accent1']) + if str(message.guild.region) == "russia": + dbregistred_content = discord.Embed(title="База данных пользователя", description="База данных пользователя зарегистрирована. Напишите команду еще раз.", color=botconfig['accent1']) + else: + dbregistred_content = discord.Embed(title="User Database", description="Database registered. Type the command again", color=botconfig['accent1']) return await message.channel.send(embed=dbregistred_content) if str(e) == "list index out of range" or str(e) == "'NoneType' object is not subscriptable": pass errorcode = discord.Embed(title="Something went wrong...", description="This bug was reported to the bot developer.\n\n```" + ex[0] + "\n" + ex[1] + "\n" + ex[2] + "\nErrorcode: " + str(e) + "```", color=botconfig['accent1']) await message.channel.send(embed=errorcode) + gc.collect() else: pass diff --git a/discord_bot/d_commands/codec.py b/discord_bot/d_commands/codec.py new file mode 100644 index 0000000..ae4e214 --- /dev/null +++ b/discord_bot/d_commands/codec.py @@ -0,0 +1,114 @@ +import base64 +import binascii + +async def decoder(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, embed_color, args, binary): + 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) + 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) + await msg.add_reaction(emoji="1️⃣") + await msg.add_reaction(emoji="2️⃣") + await msg.add_reaction(emoji="3️⃣") + await msg.add_reaction(emoji="4️⃣") + @bot.event + async def on_reaction_add(reaction, user): + channel = reaction.message.channel + if reaction.emoji == "1️⃣" and user.id != bot.user.id: + try: + result = base64.standard_b64decode(" ".join(args[2:]).encode('ascii')).decode('ascii') + except: + result = localization[1][14][6] + decoder_result_content = discord.Embed(title=str(localization[1][14][0]), color=embed_color) + decoder_result_content.add_field(name=str(localization[1][14][4]), value='```' + str(result) + '```', inline=True) + await msg.edit(embed=decoder_result_content) + if reaction.emoji == "2️⃣" and user.id != bot.user.id: + try: + result = base64.b32decode(" ".join(args[2:]).encode('ascii')).decode('ascii') + except: + result = localization[1][14][6] + decoder_result_content = discord.Embed(title=localization[1][14][0], color=embed_color) + decoder_result_content.add_field(name=str(localization[1][14][4]), value='```' + str(result) + '```', inline=True) + await msg.edit(embed=decoder_result_content) + if reaction.emoji == "3️⃣" and user.id != bot.user.id: + try: + result = base64.b16decode(" ".join(args[2:]).encode('ascii')).decode('ascii') + except: + result = localization[1][14][6] + decoder_result_content = discord.Embed(title=localization[1][14][0], color=embed_color) + decoder_result_content.add_field(name=str(localization[1][14][4]), value='```' + str(result) + '```', inline=True) + await msg.edit(embed=decoder_result_content) + if reaction.emoji == "4️⃣" and user.id != bot.user.id: + try: + result = str(binary.decode(" ".join(args[2:]))) + except Exception as e: + print(e) + result = localization[1][14][6] + decoder_result_content = discord.Embed(title=localization[1][14][0], color=embed_color) + 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): + 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) + 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) + await msg.add_reaction(emoji="1️⃣") + await msg.add_reaction(emoji="2️⃣") + await msg.add_reaction(emoji="3️⃣") + await msg.add_reaction(emoji="4️⃣") + @bot.event + async def on_reaction_add(reaction, user): + channel = reaction.message.channel + if reaction.emoji == "1️⃣" and user.id != bot.user.id: + try: + result = base64.standard_b64encode(" ".join(args[2:]).encode('ascii')).decode('ascii') + except: + result = localization[1][14][6] + decoder_result_content = discord.Embed(title=localization[1][14][0], color=embed_color) + decoder_result_content.add_field(name=str(localization[1][14][4]), value="```" + str(result) + "```", inline=True) + await msg.edit(embed=decoder_result_content) + if reaction.emoji == "2️⃣" and user.id != bot.user.id: + try: + result = base64.b32encode(" ".join(args[2:]).encode('ascii')).decode('ascii') + except: + result = localization[1][14][6] + decoder_result_content = discord.Embed(title=localization[1][14][0], color=embed_color) + decoder_result_content.add_field(name=str(localization[1][14][4]), value="```" + str(result) + "```", inline=True) + await msg.edit(embed=decoder_result_content) + if reaction.emoji == "3️⃣" and user.id != bot.user.id: + try: + result = base64.b16encode(" ".join(args[2:]).encode('ascii')).decode('ascii') + except: + result = localization[1][14][6] + decoder_result_content = discord.Embed(title=localization[1][14][0], color=embed_color) + decoder_result_content.add_field(name=str(localization[1][14][4]), value="```" + str(result) + "```", inline=True) + await msg.edit(embed=decoder_result_content) + if reaction.emoji == "4️⃣" and user.id != bot.user.id: + try: + args_str = " ".join(args[2:]) + result = "" + for letter in list(args_str): + try: + result += binary.encode()[letter] + except Exception as e: + print(e) + result += '' + except Exception as e: + result = localization[1][14][6] + print(e) + try: + decoder_result_content = discord.Embed(title=localization[1][14][0], color=embed_color) + decoder_result_content.add_field(name=str(localization[1][14][4]), value='```' + str(result) + '```', inline=True) + await msg.edit(embed=decoder_result_content) + except: + decoder_result_content = discord.Embed(title=localization[1][14][0], color=embed_color) + decoder_result_content.add_field(name=str(localization[1][14][4]), value=localization[1][14][7], inline=True) + try: + 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) + await message.channel.send(embed=help_content) \ No newline at end of file diff --git a/discord_bot/d_commands/eval.py b/discord_bot/d_commands/eval.py index bf26e23..71dc508 100644 --- a/discord_bot/d_commands/eval.py +++ b/discord_bot/d_commands/eval.py @@ -10,5 +10,8 @@ async def eval_cmd(bot, discord, message, botconfig, os, platform, datetime, one except Exception as e: result = "Обнаружено исключение!\n" + str(e) finally: + try: eval_content.add_field(name="Результат", value="```" + result + "```", inline=False) - await message.channel.send(embed=eval_content) + await message.channel.send(embed=eval_content) + except: + await message.channel.send("```" + result + "```") diff --git a/discord_bot/d_commands/guilds.py b/discord_bot/d_commands/guilds.py new file mode 100644 index 0000000..076713b --- /dev/null +++ b/discord_bot/d_commands/guilds.py @@ -0,0 +1,12 @@ +async def guilds_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, localization, guild_result, intents, embed_color): + accessdenied_msg = discord.Embed(title="Доступ запрещен", description="Эта команда защищена владельцем бота, поэтому она недоступна.", color=botconfig['accent2']) + if str(message.author.id) != botconfig['owner']: + return await message.channel.send(embed=accessdenied_msg) + 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" + except Exception as e: + guild_list = "Обнаружено исключение!\n" + str(e) + finally: + await message.channel.send("```" + guild_list + "```") \ No newline at end of file diff --git a/discord_bot/d_commands/help.py b/discord_bot/d_commands/help.py index dd7c686..089f31f 100644 --- a/discord_bot/d_commands/help.py +++ b/discord_bot/d_commands/help.py @@ -1,8 +1,38 @@ -async def help_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, embed_color): - help_content = discord.Embed(title=botconfig['name'], description=str(botconfig['name'] + localization[1][0][0]), 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) +import random + + +async def help_cmd(bot, discord, message, botconfig, platform, os, datetime, + one_result, localization, embed_color): + if localization[0] == "Russian": + tips = [ + 'Для просмотра авторской информационной программы "Новости Тинеликса" достаточно написать команду `tnews`?', + 'Все наши ссылки находятся в `info`?', + 'Узнать погоду можно в `weather`?', + 'Просмотреть рандомные фото можно в `photo`? Вдруг пригодится поставить обои на свой рабочий стол?', + 'Что в версии 01R5 (9 января 2020 г.) появилась команда `codec` для зашифровки и расшифровки текста?' + ] + else: + tips = ['All our links on `info` command'] + 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.set_footer(text='Ver. ' + botconfig['version']) + await message.channel.send(embed=help_content) diff --git a/discord_bot/d_commands/info.py b/discord_bot/d_commands/info.py new file mode 100644 index 0000000..f7abd37 --- /dev/null +++ b/discord_bot/d_commands/info.py @@ -0,0 +1,9 @@ +async def info_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, embed_color): + info_content = discord.Embed(title=botconfig['name'], color=embed_color) + 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) + info_content.set_footer(text="© Tinelix, 2020-2021") + await message.channel.send(embed=info_content) \ No newline at end of file diff --git a/discord_bot/d_commands/poll.py b/discord_bot/d_commands/poll.py new file mode 100644 index 0000000..00c4aa6 --- /dev/null +++ b/discord_bot/d_commands/poll.py @@ -0,0 +1,73 @@ +def remove_outer_symbols(s): + left = s.index("[") + 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): + args = message.content.split(" "); + args2 = message.content.split("-[]"); + parameter_option = "" + args_str = " ".join(args[1:]) + emoji_number = { + '0': '0️⃣', + '1': '1️⃣', + '2': '2️⃣', + '3': '3️⃣', + '4': '4️⃣', + '5': '5️⃣', + '6': '6️⃣', + '7': '7️⃣', + '8': '8️⃣', + '9': '9️⃣' + } + try: + question_rindex = args_str.rindex('-o', 0) + question = args_str[:question_rindex] + options_str = "" + options = [] + endtimeerr = "" + endtime = 0 + for args_index in args: + try: + endtime = int(unix_time_millis(datetime.datetime.strptime(args_index, '%Y-%m-%d=%H:%M'))) + endtimeerr = "" + except Exception as e: + print(e) + endtimeerr = "Error" + for args_index in args: + if args_index == "-o": + parameter_option += '-o' + for args_index in args2: + try: + index = args_str.index('[') + 6 + rindex = args_str.rindex(']') + 7 + options_str += remove_outer_symbols(args_index[index:rindex]) + options = options_str.split("],[") + except: + pass + if endtime < (unix_time_millis(datetime.datetime.utcnow()) + one_result[3]): + endtime = 0 + + option_str = "" + 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) + 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) + return await message.channel.send(embed=no_args) + poll = [(message.id, message.author.id, endtime - one_result[3])] + cursor.executemany("INSERT OR REPLACE INTO polls VALUES(?, ?, ?);", poll) + connection.commit() + cursor.execute("SELECT * FROM polls WHERE msgid='" + str(message.id) + "';") + poll_result = cursor.fetchone() + poll_content = discord.Embed(title=question, description=localization[1][16][2].format(str(datetime.datetime.fromtimestamp((poll_result[2] + one_result[3]) / 1000))) + "\n\n" + option_str, color=embed_color) + msg = await message.channel.send(embed=poll_content) + for opt in options: + emoji = emoji_number[str(options.index(opt))] + 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) + await message.channel.send(embed=no_args) diff --git a/discord_bot/d_commands/post.py b/discord_bot/d_commands/post.py index 1418688..2a94f24 100644 --- a/discord_bot/d_commands/post.py +++ b/discord_bot/d_commands/post.py @@ -1,5 +1,5 @@ async def post_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, unix_time_millis, embed_color): - args = message.content.split(); + args = message.content.split(" "); guild_community = "" for guild_features in message.guild.features: if guild_features == "COMMUNITY": diff --git a/discord_bot/d_commands/profile.py b/discord_bot/d_commands/profile.py index 534b63b..598fac4 100644 --- a/discord_bot/d_commands/profile.py +++ b/discord_bot/d_commands/profile.py @@ -1,202 +1,325 @@ -async def get_user(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, args, unix_time_millis, connection, cursor, intents, lastmsgtime, embed_color): - try: - subargs = args[2] - except: - subargs = "" - if one_result[3] < 0: - your_timezone = "-" + str(-round(one_result[3] / 60 / 60 / 1000, 1)) - if one_result[3] > 0: - your_timezone = "+" + str(round(one_result[3] / 60 / 60 / 1000, 1)) - if one_result[3] == 0: - your_timezone = "" - try: - a_user = await message.guild.fetch_member(subargs) - except: - a_user = message.author - try: - argsuser = [(a_user.id, 'Russian', 0, 10800000, unix_time_millis(message.created_at), 'Disabled', 0)] - cursor.executemany("INSERT OR IGNORE INTO users VALUES(?, ?, ?, ?, ?, ?, ?);", argsuser) - connection.commit() - except: - pass - if a_user.bot == True: - bot_detector = localization[1][3][7] - else: - bot_detector = "" - if a_user.nick == None: - nick = "_Отсутствует_" - else: - nick = a_user.nick - result = cursor.execute("SELECT * FROM users WHERE userid = " + str(a_user.id) + ";").fetchone() - if result[5] == "Disabled": - msgcounter = localization[1][3][6] - else: - msgcounter = str(result[2]) + str(localization[1][3][5]) - if a_user.raw_status == "online": - user_status = localization[1][3][11][0] - if a_user.raw_status == "idle": - user_status = localization[1][3][11][1] - if a_user.raw_status == "dnd": - user_status = localization[1][3][11][2] - if a_user.raw_status == "offline": - user_status = localization[1][3][11][3] - joindate_ms = int(unix_time_millis(a_user.joined_at) + one_result[3]) - joindate = datetime.datetime.fromtimestamp((joindate_ms) / 1000) # 25200000 for UTC+7 - regdate_ms = int(unix_time_millis(a_user.created_at) + one_result[3]) - regdate = datetime.datetime.fromtimestamp((regdate_ms) / 1000) # 25200000 for UTC+7 - try: - if a_user.id == message.author.id: - prepostdate_ms = int(lastmsgtime + one_result[3]) - else: - prepostdate_ms = int(result[6] + one_result[3]) - except: - prepostdate_ms = 0 - try: - prepostdate = datetime.datetime.fromtimestamp(( prepostdate_ms) / 1000) # 25200000 for UTC+7 - except: - pass - dbregdate_ms = result[4] - dbregdate = datetime.datetime.fromtimestamp(dbregdate_ms / 1000) - member_roles_a = "" - for member_roles in a_user.roles: - if member_roles.name != "@everyone": - if a_user.roles.index(member_roles) < len(a_user.roles) - 1: - member_roles_a += str(member_roles.name) + ", " - else: - member_roles_a += str(member_roles.name) - else: - member_roles_a += "" - if member_roles_a == "" or member_roles_a == None: - member_roles_a = "_Нет_" - userprofile_content = discord.Embed(title=bot_detector + str(localization[1][3][0]) + str(a_user), description="**ID: **" + str(a_user.id), color=embed_color) - userprofile_content.add_field(name=str(localization[1][3][1]), value=str(nick), inline=True) - userprofile_content.add_field(name=str(localization[1][3][10]), value=user_status, inline=False) - userprofile_content.add_field(name=str(localization[1][3][4]) + dbregdate.strftime("%Y-%m"), value=msgcounter, inline=False) - userprofile_content.add_field(name=str(localization[1][3][2]), value=joindate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + ")", inline=False) - userprofile_content.set_thumbnail(url=str(a_user.avatar_url_as(format=None, static_format="jpeg", size=4096))) - userprofile_content.add_field(name=str(localization[1][3][3]), value=regdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + ")", inline=False) - try: - userprofile_content.add_field(name=str(localization[1][3][12]) + "(" + str(len(a_user.roles) - 1) + ")", value=member_roles_a, inline=False) - except: - userprofile_content.add_field(name=str(localization[1][3][12]) + "(" + str(0) + ")", value="(пусто)", inline=False) - try: - userprofile_content.add_field(name=str(localization[1][3][13]), value=prepostdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + ")", inline=False) - except: - pass - msg = await message.channel.send(embed=userprofile_content) - if str(a_user.avatar_url_as(format=None, static_format="jpeg", size=4096)) != "" or str(a_user.avatar_url_as(format=None, static_format="jpeg", size=4096)) != None: - await msg.add_reaction(emoji="ℹ️") - await msg.add_reaction(emoji="🖼️") - avatar_content = discord.Embed(title=str(localization[1][3][8]) + str(a_user) + str(localization[1][3][9]), color=embed_color) - avatar_content.set_image(url=str(a_user.avatar_url_as(format=None, static_format="jpeg", size=4096))) - updated = 0 - @bot.event - async def on_member_update(before, after): - if after.id == a_user.id and msg.guild.id == after.guild.id: - print(after.name + " | " + str(after.raw_status)) - if after.raw_status == "online": - user_status = localization[1][3][11][0] - if after.raw_status == "idle": - user_status = localization[1][3][11][1] - if after.raw_status == "dnd": - user_status = localization[1][3][11][2] - else: - user_status = localization[1][3][11][3] - if after.nick == None: - nick = "_Отсутствует_" - else: - nick = after.nick - userprofile_changed = discord.Embed(title=bot_detector + str(localization[1][3][0]) + str(after), description="**ID: **" + str(after.id), color=embed_color) - userprofile_changed.add_field(name=str(localization[1][3][1]), value=str(nick), inline=True) - userprofile_changed.add_field(name=str(localization[1][3][10]), value=user_status, inline=False) - userprofile_changed.add_field(name=str(localization[1][3][4]) + dbregdate.strftime("%Y-%m"), value=msgcounter, inline=False) - userprofile_changed.add_field(name=str(localization[1][3][2]), value=joindate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + ")", inline=False) - userprofile_changed.set_thumbnail(url=str(after.avatar_url_as(format=None, static_format="jpeg", size=4096))) - userprofile_changed.add_field(name=str(localization[1][3][3]), value=regdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + ")", inline=False) - try: - userprofile_changed.add_field(name=str(localization[1][3][13]), value=prepostdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + ")", inline=False) - except: - pass - await msg.edit(embed=userprofile_changed) +async def get_user(bot, discord, message, botconfig, platform, os, datetime, + one_result, localization, args, unix_time_millis, + connection, cursor, intents, lastmsgtime, embed_color): + try: + subargs = args[2] + except: + subargs = "" + if one_result[3] < 0: + your_timezone = "-" + str(-round(one_result[3] / 60 / 60 / 1000, 1)) + if one_result[3] > 0: + your_timezone = "+" + str(round(one_result[3] / 60 / 60 / 1000, 1)) + if one_result[3] == 0: + your_timezone = "" + try: + a_user = await message.guild.fetch_member(subargs) + except: + a_user = message.author + try: + argsuser = [(a_user.id, 'Russian', 0, 10800000, + unix_time_millis(message.created_at), 'Disabled', 0)] + cursor.executemany( + "INSERT OR IGNORE INTO users VALUES(?, ?, ?, ?, ?, ?, ?);", + argsuser) + connection.commit() + except: + pass + if a_user.bot == True: + bot_detector = localization[1][3][7] + else: + bot_detector = "" + if a_user.nick == None: + nick = "_Отсутствует_" + else: + nick = a_user.nick + result = cursor.execute("SELECT * FROM users WHERE userid = " + + str(a_user.id) + ";").fetchone() + if result[5] == "Disabled": + msgcounter = localization[1][3][6] + else: + msgcounter = str(result[2]) + str(localization[1][3][5]) + if a_user.raw_status == "online": + user_status = localization[1][3][11][0] + if a_user.raw_status == "idle": + user_status = localization[1][3][11][1] + if a_user.raw_status == "dnd": + user_status = localization[1][3][11][2] + if a_user.raw_status == "offline": + user_status = localization[1][3][11][3] + joindate_ms = int(unix_time_millis(a_user.joined_at) + one_result[3]) + joindate = datetime.datetime.fromtimestamp( + (joindate_ms) / 1000) # 25200000 for UTC+7 + regdate_ms = int(unix_time_millis(a_user.created_at) + one_result[3]) + regdate = datetime.datetime.fromtimestamp( + (regdate_ms) / 1000) # 25200000 for UTC+7 + try: + if a_user.id == message.author.id: + prepostdate_ms = int(lastmsgtime + one_result[3]) + else: + prepostdate_ms = int(result[6] + one_result[3]) + except: + prepostdate_ms = 0 + try: + prepostdate = datetime.datetime.fromtimestamp( + (prepostdate_ms) / 1000) # 25200000 for UTC+7 + except: + pass + dbregdate_ms = result[4] + dbregdate = datetime.datetime.fromtimestamp(dbregdate_ms / 1000) + member_roles_a = "" + for member_roles in a_user.roles: + if member_roles.name != "@everyone": + if a_user.roles.index(member_roles) < len(a_user.roles) - 1: + member_roles_a += str(member_roles.name) + ", " + else: + member_roles_a += str(member_roles.name) + else: + member_roles_a += "" + if member_roles_a == "" or member_roles_a == None: + member_roles_a = "_Нет_" + userprofile_content = discord.Embed( + title=bot_detector + str(localization[1][3][0]) + str(a_user), + description="**ID: **" + str(a_user.id) + "\n**" + str(localization[1][3][14] + ": **" + str(one_result[7])), + color=embed_color) + userprofile_content.add_field( + name=str(localization[1][3][1]), value=str(nick), inline=True) + userprofile_content.add_field( + name=str(localization[1][3][10]), value=user_status, inline=False) + userprofile_content.add_field( + name=str(localization[1][3][4]) + dbregdate.strftime("%Y-%m"), + value=msgcounter, + inline=False) + userprofile_content.add_field( + name=str(localization[1][3][2]), + value=joindate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + + ")", + inline=False) + userprofile_content.set_thumbnail( + url=str( + a_user.avatar_url_as(format=None, static_format="jpeg", + size=4096))) + userprofile_content.add_field( + name=str(localization[1][3][3]), + value=regdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + + ")", + inline=False) + try: + userprofile_content.add_field( + name=str(localization[1][3][12]) + "(" + + str(len(a_user.roles) - 1) + ")", + value=member_roles_a, + inline=False) + except: + userprofile_content.add_field( + name=str(localization[1][3][12]) + "(" + str(0) + ")", + value="(пусто)", + inline=False) + try: + userprofile_content.add_field( + name=str(localization[1][3][13]), + value=prepostdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + + your_timezone + ")", + inline=False) + except: + pass + msg = await message.channel.send(embed=userprofile_content) + if str(a_user.avatar_url_as( + format=None, static_format="jpeg", size=4096)) != "" or str( + a_user.avatar_url_as(format=None, static_format="jpeg", + size=4096)) != None: + await msg.add_reaction(emoji="ℹ️") + await msg.add_reaction(emoji="🖼️") + avatar_content = discord.Embed( + title=str(localization[1][3][8]) + str(a_user) + str( + localization[1][3][9]), + color=embed_color) + avatar_content.set_image( + url=str( + a_user.avatar_url_as(format=None, static_format="jpeg", + size=4096))) + updated = 0 - @bot.event - async def on_reaction_add(reaction, user): - channel = reaction.message.channel - if reaction.emoji == "ℹ️" and user.id != bot.user.id: - await msg.edit(embed=userprofile_content) - if reaction.emoji == "🖼️" and user.id != bot.user.id: - await msg.edit(embed=avatar_content) - if reaction.emoji == "🗨️" and user.id != bot.user.id: - await msg.edit(embed=userprofile_content) + @bot.event + async def on_member_update(before, after): + if after.id == a_user.id and msg.guild.id == after.guild.id: + print(after.name + " | " + str(after.raw_status)) + if after.raw_status == "online": + user_status = localization[1][3][11][0] + if after.raw_status == "idle": + user_status = localization[1][3][11][1] + if after.raw_status == "dnd": + user_status = localization[1][3][11][2] + else: + user_status = localization[1][3][11][3] + if after.nick == None: + nick = "_Отсутствует_" + else: + nick = after.nick + userprofile_changed = discord.Embed( + title=bot_detector + str(localization[1][3][0]) + str(after), + description="**ID: **" + str(after.id), + color=embed_color) + userprofile_changed.add_field( + name=str(localization[1][3][1]), value=str(nick), inline=True) + userprofile_changed.add_field( + name=str(localization[1][3][10]), + value=user_status, + inline=False) + userprofile_changed.add_field( + name=str(localization[1][3][4]) + dbregdate.strftime("%Y-%m"), + value=msgcounter, + inline=False) + userprofile_changed.add_field( + name=str(localization[1][3][2]), + value=joindate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + + your_timezone + ")", + inline=False) + userprofile_changed.set_thumbnail( + url=str( + after.avatar_url_as( + format=None, static_format="jpeg", size=4096))) + userprofile_changed.add_field( + name=str(localization[1][3][3]), + value=regdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + + your_timezone + ")", + inline=False) + try: + userprofile_changed.add_field( + name=str(localization[1][3][13]), + value=prepostdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + + your_timezone + ")", + inline=False) + except: + pass + await msg.edit(embed=userprofile_changed) -async def get_help(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, args, unix_time_millis, connection, cursor, embed_color): - if one_result[3] < 0: - your_timezone = "-" + str(-round(one_result[3] / 60 / 60 / 1000, 1)) - if one_result[3] > 0: - your_timezone = "+" + str(round(one_result[3] / 60 / 60 / 1000, 1)) - if one_result[3] == 0: - your_timezone = "" - if one_result[5] == "Disabled": - msgcounter = str(localization[1][5][7]) - else: - msgcounter = str(localization[1][5][3]) - profilehelp_content = discord.Embed(title=str(localization[1][5][0]), description=str(localization[1][5][2]) + 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]), color=embed_color) - await message.channel.send(embed=profilehelp_content) + @bot.event + async def on_reaction_add(reaction, user): + channel = reaction.message.channel + if reaction.emoji == "ℹ️" and user.id != bot.user.id: + await msg.edit(embed=userprofile_content) + if reaction.emoji == "🖼️" and user.id != bot.user.id: + await msg.edit(embed=avatar_content) + if reaction.emoji == "🗨️" and user.id != bot.user.id: + await msg.edit(embed=userprofile_content) -async def get_guild(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, args, unix_time_millis, connection, cursor, guild_result, intents, embed_color): - if one_result[3] < 0: - your_timezone = "-" + str(-round(one_result[3] / 60 / 60 / 1000, 1)) - if one_result[3] > 0: - your_timezone = "+" + str(round(one_result[3] / 60 / 60 / 1000, 1)) - if one_result[3] == 0: - your_timezone = "" - if message.guild.explicit_content_filter == "disabled": - explicit_cf = str(localization[1][4][14][0]) - else: - explicit_cf = str(localization[1][4][14][1]) - if message.guild.mfa_level == 0: - mfa_level = str(localization[1][4][13][0]) - if message.guild.mfa_level == 1: - mfa_level = str(localization[1][4][13][1]) - if message.guild.mfa_level == 2: - mfa_level = str(localization[1][4][13][2]) - if message.guild.mfa_level == 3: - mfa_level = str(localization[1][4][13][3]) - birthdate_ms = int(unix_time_millis(message.guild.created_at) + one_result[3]) - birthdate = datetime.datetime.fromtimestamp((birthdate_ms - 25200000) / 1000) # 25200000 for UTC+7 - guildprofile_content = discord.Embed(title=str(localization[1][4][0]) + str(message.guild.name) + str(localization[1][4][1]), description="**ID: **" + str(message.guild.id), color=embed_color) - guild_community = "" - guild_online_members = [] - for guild_members in message.guild.members: - if guild_members.status != discord.Status.offline: - guild_online_members.append(str(guild_members)) - for guild_features in message.guild.features: - if guild_features == "COMMUNITY": - guild_community = "COMMUNITY" - if guild_community == "COMMUNITY": - rules_ch = "<#" + str(message.guild.rules_channel.id) + ">" - description = message.guild.description - else: - rules_ch = localization[1][4][14][2] - description = localization[1][4][14][2] - if message.guild.afk_channel != None: - afk_ch = message.guild.afk_channel.name - else: - afk_ch = localization[1][4][14][3] - if guild_result[4] == "Disabled": - msgcounter = localization[1][4][17] - else: - msgcounter = str(guild_result[2]) - owner = await message.guild.fetch_member(message.guild.owner_id) - guildprofile_content.add_field(name=str(localization[1][4][2]), value=str(description), inline=False) - guildprofile_content.add_field(name=str(localization[1][4][3]), value=str(owner.name + "#" + owner.discriminator), inline=True) - guildprofile_content.add_field(name=str(localization[1][4][4]), value=str(birthdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + ")"), inline=True) - guildprofile_content.add_field(name=str(localization[1][4][16]), value=str(msgcounter), inline=True) - guildprofile_content.add_field(name=str(localization[1][4][5]), value=str(localization[1][4][15][0]) + str(message.guild.premium_subscription_count) + str(localization[1][4][15][1]) + str(len(message.guild.premium_subscribers)), inline=True) - guildprofile_content.add_field(name=str(localization[1][4][6]), value=str(localization[1][4][15][2]) + str(len(message.guild.text_channels)) + str(localization[1][4][15][3]) + str(len(message.guild.voice_channels)), inline=True) - guildprofile_content.add_field(name=str(localization[1][4][7]), value=str(localization[1][4][15][4]) + str(message.guild.member_count) + str(localization[1][4][15][5]) + str(len(guild_online_members)), inline=True) - guildprofile_content.add_field(name=str(localization[1][4][8]), value=explicit_cf, inline=True) - guildprofile_content.add_field(name=str(localization[1][4][9]), value=rules_ch, inline=True) - guildprofile_content.add_field(name=str(localization[1][4][10]), value=afk_ch, inline=True) - guildprofile_content.set_thumbnail(url=str(message.guild.icon_url_as(format=None, static_format="jpeg", size=4096))) - await message.channel.send(embed=guildprofile_content) + +async def get_help(bot, discord, message, botconfig, platform, os, datetime, + one_result, localization, args, unix_time_millis, + connection, cursor, embed_color): + if one_result[3] < 0: + your_timezone = "-" + str(-round(one_result[3] / 60 / 60 / 1000, 1)) + if one_result[3] > 0: + your_timezone = "+" + str(round(one_result[3] / 60 / 60 / 1000, 1)) + if one_result[3] == 0: + your_timezone = "" + if one_result[5] == "Disabled": + msgcounter = str(localization[1][5][7]) + else: + msgcounter = str(localization[1][5][3]) + profilehelp_content = discord.Embed( + title=str(localization[1][5][0]), + description=str(localization[1][5][2]) + 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]), + color=embed_color) + await message.channel.send(embed=profilehelp_content) + + +async def get_guild(bot, discord, message, botconfig, platform, os, datetime, + one_result, localization, args, unix_time_millis, + connection, cursor, guild_result, intents, embed_color): + if one_result[3] < 0: + your_timezone = "-" + str(-round(one_result[3] / 60 / 60 / 1000, 1)) + if one_result[3] > 0: + your_timezone = "+" + str(round(one_result[3] / 60 / 60 / 1000, 1)) + if one_result[3] == 0: + your_timezone = "" + if message.guild.explicit_content_filter == "disabled": + explicit_cf = str(localization[1][4][14][0]) + else: + explicit_cf = str(localization[1][4][14][1]) + if message.guild.mfa_level == 0: + mfa_level = str(localization[1][4][13][0]) + if message.guild.mfa_level == 1: + mfa_level = str(localization[1][4][13][1]) + if message.guild.mfa_level == 2: + mfa_level = str(localization[1][4][13][2]) + if message.guild.mfa_level == 3: + mfa_level = str(localization[1][4][13][3]) + birthdate_ms = int( + unix_time_millis(message.guild.created_at) + one_result[3]) + birthdate = datetime.datetime.fromtimestamp( + (birthdate_ms - 25200000) / 1000) # 25200000 for UTC+7 + guildprofile_content = discord.Embed( + title=str(localization[1][4][0]) + str(message.guild.name) + str( + localization[1][4][1]), + description="**ID: **" + str(message.guild.id), + color=embed_color) + guild_community = "" + guild_online_members = [] + for guild_members in message.guild.members: + if guild_members.status != discord.Status.offline: + guild_online_members.append(str(guild_members)) + for guild_features in message.guild.features: + if guild_features == "COMMUNITY": + guild_community = "COMMUNITY" + if guild_community == "COMMUNITY": + rules_ch = "<#" + str(message.guild.rules_channel.id) + ">" + description = message.guild.description + else: + rules_ch = localization[1][4][14][2] + description = localization[1][4][14][2] + if message.guild.afk_channel != None: + afk_ch = message.guild.afk_channel.name + else: + afk_ch = localization[1][4][14][3] + if guild_result[4] == "Disabled": + msgcounter = localization[1][4][17] + else: + msgcounter = str(guild_result[2]) + owner = await message.guild.fetch_member(message.guild.owner_id) + guildprofile_content.add_field( + name=str(localization[1][4][2]), value=str(description), inline=False) + guildprofile_content.add_field( + name=str(localization[1][4][3]), + value=str(owner.name + "#" + owner.discriminator), + inline=True) + guildprofile_content.add_field( + name=str(localization[1][4][4]), + value=str( + birthdate.strftime("%Y-%m-%d %H:%M:%S") + " (UTC" + your_timezone + + ")"), + inline=True) + guildprofile_content.add_field( + name=str(localization[1][4][16]), value=str(msgcounter), inline=True) + guildprofile_content.add_field( + name=str(localization[1][4][5]), + value=str(localization[1][4][15][0]) + str( + message.guild.premium_subscription_count) + str( + localization[1][4][15][1]) + str( + len(message.guild.premium_subscribers)), + inline=True) + guildprofile_content.add_field( + name=str(localization[1][4][6]), + value=str(localization[1][4][15][2]) + str( + len(message.guild.text_channels)) + str(localization[1][4][15][3]) + + str(len(message.guild.voice_channels)), + inline=True) + guildprofile_content.add_field( + name=str(localization[1][4][7]), + value=str(localization[1][4][15][4]) + str(message.guild.member_count) + + str(localization[1][4][15][5]) + str(len(guild_online_members)), + inline=True) + guildprofile_content.add_field( + name=str(localization[1][4][8]), value=explicit_cf, inline=True) + guildprofile_content.add_field( + name=str(localization[1][4][9]), value=rules_ch, inline=True) + guildprofile_content.add_field( + name=str(localization[1][4][10]), value=afk_ch, inline=True) + guildprofile_content.set_thumbnail( + url=str( + message.guild.icon_url_as( + format=None, static_format="jpeg", size=4096))) + await message.channel.send(embed=guildprofile_content) diff --git a/discord_bot/d_commands/reputation.py b/discord_bot/d_commands/reputation.py new file mode 100644 index 0000000..e69b04c --- /dev/null +++ b/discord_bot/d_commands/reputation.py @@ -0,0 +1,75 @@ +async def rep_cmd(bot, discord, message, botconfig, platform, os, datetime, one_result, localization, embed_color, connection, cursor): + 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]) + 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) + if args[1] == str(one_result[0]): + return await message.channel.send(embed=rep_err_b) + except: + return await message.channel.send(embed=no_args) + try: + rep_content = discord.Embed(title=str(localization[1][17][0]), description=str(localization[1][17][1]), color=embed_color) + msg = await message.channel.send(embed=rep_content) + await msg.add_reaction(emoji="👍") + await msg.add_reaction(emoji="👎") + @bot.event + async def on_reaction_add(reaction, user): + channel = reaction.message.channel + if reaction.emoji == "👍" and user.id != bot.user.id: + rep_content = discord.Embed(title=str(localization[1][17][0]), description=str(localization[1][17][4]), color=embed_color) + rep_err_a = discord.Embed(title=str(localization[1][17][0]), description=str(localization[1][17][7]), color=embed_color) + rep_err_c = discord.Embed(title=str(localization[1][17][0]), description=str(localization[1][17][8]), color=embed_color) + userdb = one_result + rep = cursor.execute("SELECT * FROM reputations WHERE userid = " + + str(message.author.id) + " AND repid = "+ str(args[1]) + " ;").fetchone() + + #print(str(userdb) + " | " + str(rep)) + if userdb == None: + return await msg.edit(embed=rep_err_a) + try: + if rep[3] == "False": + return await msg.edit(embed=rep_err_c) + except: + pass + if rep == None or rep[3] == "False": + if rep == None: + reputation = [(message.id, message.author.id, args[1], 'True', 'False')] + else: + reputation = [(rep[0], rep[1], rep[2], 'True', 'False')] + cursor.executemany("INSERT OR REPLACE INTO reputations VALUES(?, ?, ?, ?, ?);", reputation) + connection.commit() + user_rep = [(userdb[0], userdb[1], userdb[2], userdb[3], userdb[4], userdb[5], userdb[6], userdb[7] + 1, userdb[8], userdb[9])] + cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", user_rep) + connection.commit() + await msg.edit(embed=rep_content) + if reaction.emoji == "👎" and user.id != bot.user.id: + rep_content = discord.Embed(title=str(localization[1][17][0]), description=str(localization[1][17][3]), color=embed_color) + rep_err_a = discord.Embed(title=str(localization[1][17][0]), description=str(localization[1][17][7]), color=embed_color) + rep_err_c = discord.Embed(title=str(localization[1][17][0]), description=str(localization[1][17][9]), color=embed_color) + rep = cursor.execute("SELECT * FROM reputations WHERE userid = " + + str(message.author.id) + " AND repid = "+ str(args[1]) + " ;").fetchone() + userdb = one_result + if userdb == None: + return await msg.edit(embed=rep_err_a) + try: + if rep[3] == "False": + return await msg.edit(embed=rep_err_c) + except: + pass + if rep == None or rep[3] == "True": + if rep == None: + reputation = [(message.id, message.author.id, args[1], 'False', 'True')] + else: + reputation = [(rep[0], rep[1], rep[2], 'False', 'True')] + cursor.executemany("INSERT OR REPLACE INTO reputations VALUES(?, ?, ?, ?, ?);", reputation) + connection.commit() + user_rep = [(userdb[0], userdb[1], userdb[2], userdb[3], userdb[4], userdb[5], userdb[6], userdb[7] - 1, userdb[8], userdb[9])] + cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", user_rep) + connection.commit() + await msg.edit(embed=rep_content) + #cursor.executemany("INSERT OR REPLACE INTO polls VALUES(?, ?, ?);", poll) + except: + pass \ No newline at end of file diff --git a/discord_bot/d_commands/set.py b/discord_bot/d_commands/set.py index 6cb91de..7fbc8d6 100644 --- a/discord_bot/d_commands/set.py +++ b/discord_bot/d_commands/set.py @@ -4,20 +4,20 @@ async def set_bot_language(bot, discord, message, botconfig, os, platform, datet subargs = args[2] if subargs == "en-US": try: - user = [(message.author.id, 'English', one_result[2] + 1, one_result[3], one_result[4], one_result[5], unix_time_millis(message.created_at))] + user = [(message.author.id, 'English', one_result[2] + 1, one_result[3], one_result[4], one_result[5], unix_time_millis(message.created_at), one_result[7], one_result[8], one_result[9])] except: - user = [(message.author.id, 'English', 1, 10800000, unix_time_millis(message.created_at), 'Enabled', unix_time_millis(message.created_at))] - cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?);", user) + user = [(message.author.id, 'English', 1, 10800000, unix_time_millis(message.created_at), 'Enabled', unix_time_millis(message.created_at), 0, 0 ,0)] + cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", user) connection.commit() current_language = "English" botlanguage_content = discord.Embed(title="Bot language", description="Your language choosed to " + current_language, color=botconfig['accent1']) await message.channel.send(embed=botlanguage_content) if subargs == "ru-RU": try: - user = [(message.author.id, 'Russian', one_result[2] + 1, one_result[3], one_result[4], "Enabled", unix_time_millis(message.created_at))] + user = [(message.author.id, 'Russian', one_result[2] + 1, one_result[3], one_result[4], "Enabled", unix_time_millis(message.created_at), one_result[7], one_result[8], one_result[9])] except: - user = [(message.author.id, 'Russian', 1, 10800000, unix_time_millis(message.created_at), "Enabled", unix_time_millis(message.created_at))] - cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?);", user) + user = [(message.author.id, 'Russian', 1, 10800000, unix_time_millis(message.created_at), "Enabled", unix_time_millis(message.created_at), 0, 0, 0)] + cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", user) connection.commit() current_language = "Russian" botlanguage_content = discord.Embed(title="Язык бота", description="Ваш язык выбран на " + current_language, color=botconfig['accent1']) @@ -41,10 +41,10 @@ async def set_timezone(bot, discord, message, botconfig, os, platform, datetime, if subargs2.isdigit() == True: if -int(subargs) >= -120 and -int(subargs) <= 140: try: - user = [(message.author.id, one_result[1], one_result[2] + 1, int((-int(subargs2) / 10) * 60 * 60 * 1000), one_result[4], one_result[5], unix_time_millis(message.created_at))] + user = [(message.author.id, one_result[1], one_result[2] + 1, int((-int(subargs2) / 10) * 60 * 60 * 1000), one_result[4], one_result[5], unix_time_millis(message.created_at), one_result[7], one_result[8], one_result[9])] except: - user = [(message.author.id, "Russian", 0, 10800000, unix_time_millis(message.created_at), "Enabled", unix_time_millis(message.created_at))] - cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?);", user) + user = [(message.author.id, "Russian", 0, 10800000, unix_time_millis(message.created_at), "Enabled", unix_time_millis(message.created_at), 0, 0, 0)] + cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", user) connection.commit() timezone_content = discord.Embed(title=str(localization[1][2][3][0]), description=localization[1][2][4][2] + your_timezone, color=botconfig['accent1']) await message.channel.send(embed=timezone_content) @@ -52,10 +52,10 @@ async def set_timezone(bot, discord, message, botconfig, os, platform, datetime, return await message.channel.send(embed=stringnotisdigit_content) if int(subargs) >= -120 and int(subargs) <= 140: try: - user = [(message.author.id, one_result[1], one_result[2] + 1, int((int(subargs) / 10) * 60 * 60 * 1000), one_result[4], one_result[5], unix_time_millis(message.created_at))] + user = [(message.author.id, one_result[1], one_result[2] + 1, int((int(subargs) / 10) * 60 * 60 * 1000), one_result[4], one_result[5], unix_time_millis(message.created_at), one_result[7], one_result[8], one_result[9])] except: - user = [(message.author.id, 'Russian', 1, int((subargs / 10) * 60 * 60 * 1000), unix_time_millis(message.created_at), 'Enabled', unix_time_millis(message.created_at))] - cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?);", user) + user = [(message.author.id, 'Russian', 1, int((subargs / 10) * 60 * 60 * 1000), unix_time_millis(message.created_at), 'Enabled', unix_time_millis(message.created_at), 0, 0, 0)] + cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", user) connection.commit() timezone_content = discord.Embed(title=str(localization[1][2][3][0]), description=localization[1][2][4][2] + your_timezone, color=botconfig['accent1']) await message.channel.send(embed=timezone_content) @@ -85,10 +85,10 @@ async def on_reaction_add(reaction, user): await msg.edit(embed=nopermerr_content) if reaction.emoji == "👤" and user.id != bot.user.id: try: - user = [(message.author.id, one_result[1], one_result[2], one_result[3], one_result[4], 'Enabled', unix_time_millis(message.created_at))] + user = [(message.author.id, one_result[1], one_result[2], one_result[3], one_result[4], 'Enabled', unix_time_millis(message.created_at), one_result[7], one_result[8], one_result[9])] except: - user = [(message.author.id, 'Russian', 1, 10800000, unix_time_millis(message.created_at), 'Enabled', unix_time_millis(message.created_at))] - cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?);", user) + user = [(message.author.id, 'Russian', 1, 10800000, unix_time_millis(message.created_at), 'Enabled', unix_time_millis(message.created_at), 0, 0, 0)] + cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", user) connection.commit() await msg.edit(embed=msgcounter_content) if subargs == "off": @@ -114,10 +114,10 @@ async def on_reaction_add(reaction, user): await msg.edit(embed=nopermerr_content) if reaction.emoji == "👤" and user.id != bot.user.id: try: - user = [(message.author.id, one_result[1], one_result[2], one_result[3], one_result[4], 'Disabled', unix_time_millis(message.created_at))] + user = [(message.author.id, one_result[1], one_result[2], one_result[3], one_result[4], 'Disabled', unix_time_millis(message.created_at), one_result[7], one_result[8], one_result[9])] except: - user = [(message.author.id, 'Russian', 1, 10800000, unix_time_millis(message.created_at), 'Disabled', unix_time_millis(message.created_at))] - cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?);", user) + user = [(message.author.id, 'Russian', 1, 10800000, unix_time_millis(message.created_at), 'Disabled', unix_time_millis(message.created_at), 0, 0, 0)] + cursor.executemany("INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?);", user) connection.commit() await msg.edit(embed=msgcounter_content) if subargs != "off" and subargs != "on": diff --git a/discord_bot/d_commands/state.py b/discord_bot/d_commands/state.py index fc06362..6f89ed5 100644 --- a/discord_bot/d_commands/state.py +++ b/discord_bot/d_commands/state.py @@ -9,5 +9,4 @@ async def state_cmd(bot, discord, sqlite3, message, botconfig, os, platform, dat state_content.add_field(name=str(localization[1][1][6]), value=platform.python_build()[1], inline=True) state_content.add_field(name=str(localization[1][1][7]), value="**discord.py:** " + discord.__version__ + "\n**SQLite3 library:** " + sqlite3.sqlite_version + "\n**Vision bot:** " + botconfig['version'], inline=True) state_content.add_field(name=str(localization[1][1][8]), value="🏠 " + str(len(bot.guilds)) + " | 👥 " + str(len(bot.users)) + " | 🗃 " + str(len(usersdb_count)), inline=True) - state_content.add_field(name=str(localization[1][1][9]), value="Tinelix (`" + bot.get_user(int(botconfig['owner'])).name + "#" + str(bot.get_user(int(botconfig['owner'])).discriminator) + "`)", inline=True) await message.channel.send(embed=state_content) \ No newline at end of file diff --git a/discord_bot/d_events/logging.py b/discord_bot/d_events/logging.py index f8b8abc..9ed1460 100644 --- a/discord_bot/d_events/logging.py +++ b/discord_bot/d_events/logging.py @@ -13,15 +13,15 @@ async def traceback_logger(bot, discord, message, one_result, guild_result, conn async def joining_logger(bot, discord, guild, connection, cursor, unix_time_millis, botconfig): logging_content = discord.Embed(title=botconfig['name'] + " Logger", description="Bot joined the **" + str(guild.name) + "** server! We have " + str(len(bot.guilds)) + " guilds.", color=botconfig['accent1']) logging_content.add_field(name="IDs", value="```S: " + str(guild.id) + "\nO: " + str(guild.owner_id) + "```", inline=False) - logging_content.add_field(name="Statistics", value="```Owner: " + str(guild.owner.name) + "#" + str(guild.owner.discriminator) + "\nMembers: " + str(guild.member_count) + "\nBoosts: " + str(guild.premium_subscription_count) + "\nChannels: T - " + str(len(guild.text_channels)) + ", V - " + str(len(guild.voice_channels)) + "\nRegion: " + str(guild.region) + "```", inline=False) + logging_content.add_field(name="Statistics", value="```Owner: " + str(guild.owner.name) + "#" + str(guild.owner.discriminator) + "\nMembers: " + str(guild.member_count) + "\nBoosts: " + str(guild.premium_subscription_count) + "\nChannels: Text - " + str(len(guild.text_channels)) + " | Voice - " + str(len(guild.voice_channels)) + "\nRegion: " + str(guild.region) + "```", inline=False) logging_content.set_thumbnail(url=str(guild.icon_url_as(format=None, static_format="jpeg", size=4096))) await bot.get_channel(botconfig['logs_channel']).send(embed=logging_content) -async def joining_logger(bot, discord, guild, connection, cursor, unix_time_millis, botconfig): - logging_content = discord.Embed(title=botconfig['name'] + " Logger", description="Bot joined the **" + str(guild.name) + "** server! We have " + str(len(bot.guilds)) + " guilds.", color=botconfig['accent1']) +async def leaving_logger(bot, discord, guild, connection, cursor, unix_time_millis, botconfig): + logging_content = discord.Embed(title=botconfig['name'] + " Logger", description="Bot left the **" + str(guild.name) + "** server. We have " + str(len(bot.guilds)) + " guilds.", color=botconfig['accent1']) logging_content.add_field(name="IDs", value="```S: " + str(guild.id) + "\nO: " + str(guild.owner_id) + "```", inline=False) - logging_content.add_field(name="Statistics", value="```Owner: " + str(guild.owner.name) + "#" + str(guild.owner.discriminator) + "\nMembers: " + str(guild.member_count) + "\nBoosts: " + str(guild.premium_subscription_count) + "\nChannels: T - " + str(len(guild.text_channels)) + ", V - " + str(len(guild.voice_channels)) + "\nRegion: " + str(guild.region) + "```", inline=False) + logging_content.add_field(name="Statistics", value="```Owner: " + str(guild.owner.name) + "#" + str(guild.owner.discriminator) + "\nMembers: " + str(guild.member_count) + "\nBoosts: " + str(guild.premium_subscription_count) + "\nChannels: Text - " + str(len(guild.text_channels)) + " | Voice - " + str(len(guild.voice_channels)) + "\nRegion: " + str(guild.region) + "```", inline=False) logging_content.set_thumbnail(url=str(guild.icon_url_as(format=None, static_format="jpeg", size=4096))) await bot.get_channel(botconfig['logs_channel']).send(embed=logging_content) diff --git a/discord_bot/d_languages/binary.py b/discord_bot/d_languages/binary.py new file mode 100644 index 0000000..8cd7836 --- /dev/null +++ b/discord_bot/d_languages/binary.py @@ -0,0 +1,165 @@ +import binascii +def encode(): + return { + 'A': '01000001', + 'a': '01100001', + 'B': '01000010', + 'b': '01100010', + 'C': '01000011', + 'c': '01100011', + 'D': '01000100', + 'd': '01100100', + 'E': '01000101', + 'e': '01100101', + 'F': '01000110', + 'f': '01100110', + 'G': '01000111', + 'g': '01100111', + 'H': '01001000', + 'h': '01101000', + 'I': '01001001', + 'i': '01101001', + 'M': '01001101', + 'm': '01101101', + 'N': '01001110', + 'n': '01101110', + 'O': '01001111', + 'o': '01101111', + 'P': '01010000', + 'p': '01110000', + 'Q': '01010001', + 'q': '01110001', + 'R': '01010010', + 'r': '01110010', + 'S': '01010011', + 's': '01110011', + 'T': '01010100', + 't': '01110100', + 'U': '01010101', + 'u': '01110101', + 'V': '01010110', + 'v': '01110110', + 'W': '01010111', + 'w': '01110111', + 'X': '01011000', + 'x': '01111000', + 'Y': '01011001', + 'y': '01111001', + 'Z': '01011010', + 'z': '01111010', + 'А': '1101000010010000', + 'а': '1101000010110000', + 'Б': '1101000010010001', + 'б': '1101000010110001', + 'В': '1101000010010010', + 'в': '1101000010110010', + 'Г': '1101000010010011', + 'г': '1101000010110011', + 'Д': '1101000010010100', + 'д': '1101000010110100', + 'Е': '1101000010010101', + 'е': '1101000010110101', + 'Ё': '1101000010000001', + 'ё': '1101000110010001', + 'Ж': '1101000010010110', + 'ж': '1101000010110110', + 'З': '1101000010010111', + 'з': '1101000010110111', + 'И': '1101000010011000', + 'и': '1101000010111000', + 'Й': '1101000010011001', + 'й': '1101000010111001', + 'К': '1101000010011010', + 'к': '1101000010111010', + 'Л': '1101000010011011', + 'л': '1101000010111011', + 'М': '1101000010011100', + 'м': '1101000010111100', + 'Н': '1101000010011101', + 'н': '1101000010111101', + 'О': '1101000010011110', + 'о': '1101000010111110', + 'П': '1101000010011111', + 'п': '1101000010111111', + 'Р': '1101000010100000', + 'р': '1101000110000000', + 'С': '1101000010100001', + 'с': '1101000110000001', + 'Т': '1101000010100010', + 'т': '1101000110000010', + 'У': '1101000010100011', + 'у': '1101000110000011', + 'Ф': '1101000010100100', + 'ф': '1101000110000100', + 'Х': '1101000010100101', + 'х': '1101000110000101', + 'Ц': '1101000010100110', + 'ц': '1101000110000110', + 'Ч': '1101000010100111', + 'ч': '1101000110000111', + 'Ш': '1101000010101000', + 'ш': '1101000110001000', + 'Щ': '1101000010101001', + 'щ': '1101000110001001', + 'Ъ': '1101000010101010', + 'ъ': '1101000110001010', + 'Ы': '1101000010101011', + 'ы': '1101000110001011', + 'Ь': '1101000010101100', + 'ь': '1101000110001100', + 'Э': '1101000010101101', + 'э': '1101000110001101', + 'Ю': '1101000010101110', + 'ю': '1101000110001110', + 'Я': '1101000010101111', + 'я': '1101000110001111', + '.': '00101110', + '?': '00111111', + '!': '00100001', + ' ': '00100000', + ',': '00101100', + '/': '00101111', + '\n': '00001010', + '"': '00100010', + '\'': '00100111', + ':': '00111010', + '(': '00101000', + ')': '00101001', + ';': '00111011', + '=': '00111101', + '^': '01011110', + '-': '00101101', + '|': '01111100', + '[': '01011011', + ']': '01011101', + '{': '01111011', + '}': '01111101', + '*': '00101010', + '+': '00101011', + '#': '00100011', + '$': '00100100', + '&': '00100110', + '©': '1100001010101001', + '®': '1100001010101110', + '°': '1100001010110000', + '~': '01111110', + '¢': '1100001010100010', + '£': '1100001010100011', + '¤': '1100001010100100', + '¥': '1100001010100101', + '№': '1110001010000100', + '0': '00110000', + '1': '00110001', + '2': '00110010', + '3': '00110011', + '4': '00110100', + '5': '00110101', + '6': '00110110', + '7': '00110111', + '8': '00111000', + '9': '00111001' + } + +def decode(s): + n = int(s, 2) + return binascii.unhexlify('%x' % n).decode('utf-8') \ No newline at end of file diff --git a/discord_bot/d_languages/en_US.py b/discord_bot/d_languages/en_US.py index 3594bfa..f695954 100644 --- a/discord_bot/d_languages/en_US.py +++ b/discord_bot/d_languages/en_US.py @@ -9,10 +9,10 @@ def get(): 'English', # 0 [ # 1 [ # 1.0 - ' - a bot written from scratch in Python. While it is in development, gradually adding its new features. Developed by Tinelix.\n**Prefix:** `{0}` | [Invite](https://discord.com/api/oauth2/authorize?client_id=785383439196487720&permissions=8&scope=bot) | [GitHub](https://github.com/tinelix/visionbot)'.format(prefix), # 1.0.0 + ' - simple and slightly extensible. Developed by Tinelix.\n**Prefix:** `{0}`\n\n**Did you know that...** {1}', # 1.0.0 [ # 1.0.1 'General', # 1.0.1.0 - '`help` `state` `profile` `feedback`' # 1.0.1.1 + '`help` `state` `profile` `feedback` `info`' # 1.0.1.1 ], [ # 1.0.2 'Fun', # 1.0.2.0 @@ -24,7 +24,7 @@ def get(): ], [ # 1.0.4 'Miscellaneous', # 1.0.4.0 - '`calc` `weather`' # 1.0.4.1 + '`calc` `weather` `codec` `poll`' # 1.0.4.1 ], '**Prefix:** ' # 1.0.5 ], @@ -38,7 +38,8 @@ def get(): 'Python build date', # 1.1.6 'Packages versions', # 1.1.7 'Analytics', # 1.1.8 - 'Bot author' # 1.1.9 + 'Bot author', # 1.1.9 + 'Links' # 1.1.10 ], [ # 1.2 'Settings', # 1.2.0 @@ -107,7 +108,8 @@ def get(): '<:offline_emoji:786943380085145651> Offline' ], 'Roles ', # 1.3.12 - 'Date of sending the post message' # 1.3.13 + 'Date of sending the post message', # 1.3.13 + 'Reputation' # 1.3.14 ], [ # 1.4 'About ', # 1.4.0 @@ -149,7 +151,7 @@ def get(): ], [ # 1.5 'Profile', # 1.5.0 - '`%sprofile -u [ID]` - find out information about the user.\n`{0}profile -g` - find out information about the server'.format(prefix), # 1.5.1 + '`{0}profile -u [ID]` - find out information about the user.\n`{0}profile -g` - find out information about the server'.format(prefix), # 1.5.1 'Your parameters (can be changed in `{0}settings`): '.format(prefix), # 1.5.2 'message counter enabled', # 1.5.3 'UTC', # 1.5.4 @@ -231,5 +233,50 @@ def get(): 'This command unavailable, because you don\'t have permisson to manage messages.', # 1.13.3 'Switch to the news channel first.' ], + [ # 1.14 + 'Codec', # 1.14.0 + 'You have to choose the data type to decode into a regular string. The selection is made by clicking on the appropriate reaction.', # 1.14.1 + 'You have to choose the data type to encode into a regular string. The selection is made by clicking on the appropriate reaction.', # 1.14.2 + '1️⃣ Base64\n2️⃣ Base32\n3️⃣ Base16\n4️⃣ Binary code', # 1.14.3 + 'Result', # 1.14.4 + '`{0}codec -d` - decode text\n`{0}codec -e` - encode text'.format(prefix), # 1.14.5 + 'The text could not be decoded. Invalid data type selected.', # 1.14.6 + 'Viewing in embed message is not possible.' # 1.14.7 + 'You forgot to enter text.\n\n```{0}codec -e Hello!\n{0}codec -d SGVsbG8h```'.format(prefix) # 1.14.8 + ], + [ # 1.15 + 'About bot', # 1.15.0 + '{0} is a simple and extensible bot from Tinelix. This bot is a replacement for the Highflash bot, which was crude enough to run for monitoring bots. But don\'t worry, the Vision bot has (albeit imperfect) integration with the SQlite3 database, when there was only primitive JSON in Highflash. The bot was written from scratch and took into account the mistakes made during the development of the Highflash bot. It develops not only thanks to you, but also to the author (Tinelix) with its productivity. He can ask you the weather, encrypt or decrypt texts, show random and rather interesting photos from Reddit and Unsplash, play Crystal Ball, etc.'.format(name), # 1.15.1 + 'Written in', # 1.15.2 + 'Author', # 1.15.3 + 'Bots Monitoring', # 1.15.4 + '[bots.server-discord.com](https://bots.server-discord.com/785383439196487720)\n[BotiCord](https://boticord.top/bot/785383439196487720)\n[Bots for Discord](https://botsfordiscord.com/bot/785383439196487720)', # 1.15.5 + 'Links', # 1.15.6 + '[Invite](https://discord.com/api/oauth2/authorize?client_id=785383439196487720&permissions=8&scope=bot)\n[GitHub](https://github.com/tinelix/visionbot)' # 1.15.7 + ], + [ # 1.16 + 'Polling', # 1.16.0 + '', # 1.16.1 + 'Time has gone! End time: {0}', # 1.16.2 + 'Polling is over', # 1.16.3 + 'You forgot to supply the required arguments to this or to the command enter arguments as arguments with `[` and `],`. Follow the example below. And yes, between the parentheses, a comma without any spaces is required.\n\n```{0}poll How did you meet 2021? Good or bad? -o [Awesome],[Good],[I don\'t care],[So bad] 2020-01-10=20:00```'.format(prefix), # 1.16.4 + 'The voting end date must not be earlier than today.' + ], + [ # 1.16 + 'Search for a user by discriminator', # 1.16.0 + 'Total results: {0}', # 1.16.1 + ], + [ # 1.17 + 'Reputation', # 1.17.0 + 'Do you want to promote or demote a person? The selection is made by clicking on the reaction.\n\n👍 **Promote**\n👎 **Demote**', # 1.17.1 + 'You cannot promote or demote yourself!', # 1.17.2 + 'Okay, you demoted it.', # 1.17.3 + 'Okay, you promoted it.', # 1.17.4 + 'Example', # 1.17.5 + '```{0}rep ```'.format(prefix), # 1.17.6 + 'This person is not in our database.', # 1.7.7 + 'You already promoted it.', # 1.7.8 + 'You already demoted it.' # 1.7.9 + ] ] ] \ No newline at end of file diff --git a/discord_bot/d_languages/ru_RU.py b/discord_bot/d_languages/ru_RU.py index af8843d..ff4830f 100644 --- a/discord_bot/d_languages/ru_RU.py +++ b/discord_bot/d_languages/ru_RU.py @@ -10,22 +10,22 @@ def get(): 'Russian', [ [ - ' - бот написанный с нуля на Python. Пока он находится в разработке, постепенно добавляя свои новые функции. Developed by Tinelix.\n\n**Префикс:** `{0}` | [Пригласить](https://discord.com/api/oauth2/authorize?client_id=785383439196487720&permissions=8&scope=bot) | [GitHub](https://github.com/tinelix/visionbot)'.format(prefix), + ' - простой и немного расширяемый. Developed by Tinelix. **Префикс:** `{0}`\n\n**А Вы знаете, что...** {1}', [ # 1.0.1 'Основное', # 1.0.1.0 - '`help` `state` `profile` `tnews` `feedback`' # 1.0.1.1 + '`help`, `state`, `profile`, `tnews`, `feedback`, `info`' # 1.0.1.1 ], [ # 1.0.2 'Развлечения', # 1.0.2.0 - '`photo` `8ball` (`crystball`)' # 1.0.2.1 + '`photo`, `8ball` (`crystball`)' ], - [ # 1.0.3 - 'Служебное ', # 1.0.3.0 - '`settings` `post`' # 1.0.3.1 + [ + 'Служебное', # 1.0.3.0 + '`settings`, `post`' # 1.0.3.1 ], [ # 1.0.4 'Разное', # 1.0.4.0 - '`calc` `weather`' # 1.0.4.1 + '`calc`, `weather`, `codec`, `poll`, `rep`' # 1.0.4.1 ], '**Префикс:** ' # 1.0.5 ], @@ -39,7 +39,8 @@ def get(): 'Дата сборки Python', 'Версии пакетов', 'Аналитика', - 'Автор бота' + 'Автор бота', + 'Ссылки', ], [ 'Настройки', @@ -108,7 +109,8 @@ def get(): '<:offline_emoji:786943380085145651> Оффлайн' # 1.3.11.3 ], 'Роли ', # 1.3.12 - 'Дата отправки последнего сообщ.' # 1.3.13 + 'Дата отправки последнего сообщ.', # 1.3.13 + 'Репутация' ], [ 'О сервере ', @@ -219,7 +221,7 @@ def get(): 'Ошибка', # 1.11.11 'Не удается найти город или населенный пункт по запросу.\n\nМожет, напишете по-другому?', # 1.11.12 'Код ошибки', # 1.11.13 - 'Вы забыли имя города или населенного пункта.' # 1.11.14 + 'Вы забыли дописать имя города или населенного пункта.' # 1.11.14 ], [ # 1.12 'Магический шар', # 1.12.0 @@ -239,9 +241,43 @@ def get(): [ # 1.14 'Кодек', # 1.14.0 'Вам предстоит выбрать тип данных для декодирования в обычную строку. Выбор типа осуществляется нажатием на соответствующую реакцию.', # 1.14.1 - 'Вам предстоит выбрать тип данных для кодирования из обычной строки. Выбор типа осуществляется нажатием на соответствующую реакцию.', # 1.14.1 - '1️⃣ Base64\n2️⃣ Base32\n3️⃣ Base16\n4️⃣ Двоичный код', # 1.14.2 - 'Результат' + 'Вам предстоит выбрать тип данных для кодирования из обычной строки. Выбор типа осуществляется нажатием на соответствующую реакцию.', # 1.14.2 + '1️⃣ Base64\n2️⃣ Base32\n3️⃣ Base16\n4️⃣ Двоичный код', # 1.14.3 + 'Результат', + '`{0}codec -d` - расшифровка текста\n`{0}codec -e` - зашифровка текста'.format(prefix), + 'Расшифровать не получилось. Неверно выбран тип данных.', + 'Просмотр в Embed-сообщении невозможен.', + 'Вы забыли ввести текст.\n\n```{0}codec -e Привет!\n{0}codec -d SGVsbG8h```'.format(prefix) + ], + [ # 1.15 + 'О боте', # 1.15.0 + '{0} - простой и расширяемый бот от Tinelix. Этот бот является заменой бота Highflash, который был достаточно сырым для запуска на мониторинг ботов. Но не беспокойтесь, в боте Vision есть (пускай, неидеальная) интеграция с БД SQlite3, когда в Highflash был только примитивный JSON. Бот написан с нуля и учитывал ошибки, допущенные при разработке бота Highflash. Теперь он развивается не только благодаря Вам, но и авторе (Tinelix\'у) своей продуктивностью.\n\nОн может узнавать погоду в Вашем городе, шифровать или расшифровать тексты, показывать случайные и довольно интересные фотографии с Reddit и Unsplash, поиграть в \"Шар судьбы\" и т. д.\n\n_Бот Vision и его открытый исходный код распространяются с условиями лицензии Affero GPL версии 3 для веб-приложений_'.format(name), # 1.15.1 + 'Написан на', # 1.15.2 + 'Автор', # 1.15.3 + 'Мониторинги ботов', # 1.15.4 + '[bots.server-discord.com](https://bots.server-discord.com/785383439196487720)\n[BotiCord](https://boticord.top/bot/785383439196487720)\n[Bots for Discord](https://botsfordiscord.com/bot/785383439196487720)', # 1.15.5 + 'Ссылки', # 1.15.5 + '[Пригласить бота](https://discord.com/api/oauth2/authorize?client_id=785383439196487720&permissions=8&scope=bot)\n[GitHub](https://github.com/tinelix/visionbot)\n[ВКонтакте](https://vk.com/tinelix)\n[YouTube](https://www.youtube.com/channel/UCSPjn_Y0pLdPy6Ncb9NAdww)\n[Сервер в Discord](https://discord.gg/fYRjHvXntj)' # 1.15.6 + ], + [ # 1.16 + 'Голосование', # 1.16.0 + 'Вести это голосование могут только администраторы сервера.', # 1.16.1 + 'Время пошло! Время окончания: {0}', # 1.16.2 + 'Голосование закончено.', # 1.16.3 + 'Вы забыли указать требуемые аргументы к этой команде или разделить аргументы знаками `[` и `],`. Следуйте примером внизу. И да, между скобками запятая без каких-либо пробелов обязательна.\n\n```{0}poll Как встретили 2021 год? Хорошо или плохо? -o [Отлично],[Хорошо],[А мне все равно],[Ужасно] 2020-01-10=20:00```'.format(prefix), # 1.16.4 + 'Дата окончания голосования не должна быть раньше, чем сегодняшняя.' + ], + [ # 1.17 + 'Репутация', + 'Вы хотите повысить или понизить человека? Выбор осуществляется нажатием на реакцию.\n\n👍 **Повысить**\n👎 **Понизить**', + 'Повышать или понижать самого себя нельзя!', + 'Окей, Вы его понизили.', + 'Окей, Вы его повысили.', + 'Пример', + '```{0}rep ```'.format(prefix), + 'Этого человека нет в нашей базе данных.', + 'Вы его уже повысили.', + 'Вы его уже понизили.' ] ] ] diff --git a/discord_bot/discord_botconfig.py b/discord_bot/discord_botconfig.py index 7a53f61..f807910 100644 --- a/discord_bot/discord_botconfig.py +++ b/discord_bot/discord_botconfig.py @@ -6,13 +6,13 @@ botconfig = { 'token': os.environ['DTOKEN'], - 'name': 'Vision', + 'name': 'VisionOne', 'id': 785383439196487720, 'prefix': '=', 'accent1': 0xd7832a, 'accent2': 0xcb3532, 'accent3': 0x6eda5f, - 'version': '01R5-210108', + 'version': '01R7-210113', 'owner': '741883312108339231', 'logs_channel': 788723868255649832, 'unsplash_ak': os.environ['UNSAKEY'], diff --git a/main.py b/main.py index b4acc6a..42b9dcd 100644 --- a/main.py +++ b/main.py @@ -1,3 +1 @@ import discord_bot.bot_d -import keep_alive -keep_alive.keep_alive() \ No newline at end of file