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

Commit

Permalink
Sixth commit - January 18, 2021 (01R7-210118)
Browse files Browse the repository at this point in the history
  • Loading branch information
tretdm committed Jan 18, 2021
1 parent ad3e76d commit 686f791
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 37 deletions.
9 changes: 6 additions & 3 deletions discord_bot/bot_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import numexpr
import gc
import keep_alive
import cpuinfo
import psutil

keep_alive.keep_alive()

from requests.auth import HTTPBasicAuth
Expand Down Expand Up @@ -347,7 +350,7 @@ async def on_message(message):
else:
await help_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result, en_US.get(), botconfig['accent1'])
if message.content.startswith(botconfig['prefix'] + 'state'):
await state_cmd(bot, discord, sqlite3, message, botconfig, os, platform, datetime, one_result, localization, embed_color, connection, cursor)
await state_cmd(bot, discord, sqlite3, message, botconfig, os, platform, datetime, one_result, localization, embed_color, connection, cursor, cpuinfo, psutil)
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'):
Expand All @@ -366,9 +369,9 @@ async def on_message(message):
if args[1] == "-tz":
await settings.set_timezone(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis)
if args[1] == "-mc":
await settings.switch_msgcounter(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis)
await settings.switch_msgcounter(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis,guild_result)
if args[1] == "-ec":
await settings.set_embed_color(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis, embed_color)
await settings.set_embed_color(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis, embed_color, guild_result)
if args[1] == "-welcm":
await settings.set_welcome_message(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis, embed_color)
if args[1] == "-byem":
Expand Down
3 changes: 2 additions & 1 deletion discord_bot/d_commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ async def help_cmd(bot, discord, message, botconfig, platform, os, datetime,
'Все наши ссылки находятся в `info`?',
'Узнать погоду можно в `weather`?',
'Просмотреть рандомные фото можно в `photo`? Вдруг пригодится поставить обои на свой рабочий стол?',
'Что в версии 01R5 (9 января 2020 г.) появилась команда `codec` для зашифровки и расшифровки текста?'
'Что в версии 01R5 (9 января 2020 г.) появилась команда `codec` для зашифровки и расшифровки текста?',
'Зайти на наш саппорт-сервер можно по [ссылке](https://discord.gg/HAt6K2QuJU)'
]
else:
tips = ['All our links on `info` command']
Expand Down
24 changes: 12 additions & 12 deletions discord_bot/d_commands/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def set_timezone(bot, discord, message, botconfig, os, platform, datetime,
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)

async def switch_msgcounter(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis):
async def switch_msgcounter(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis, guild_result):
subargs = args[2]
if subargs == "on":
msgcounter_choice = discord.Embed(title=str(localization[1][2][5][0]), description=str(localization[1][2][5][1]), color=botconfig['accent1'])
Expand All @@ -75,7 +75,7 @@ async def on_reaction_add(reaction, user):
if reaction.emoji == "🏠" and user.id != bot.user.id:
if message.author.guild_permissions.manage_guild == True:
try:
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], 'Disabled', one_result[5], one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_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])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Enabled', 'Standart', '=', 'English', 0, '', 0, '')]
cursor.executemany("INSERT OR REPLACE INTO guilds VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", guild)
Expand Down Expand Up @@ -104,7 +104,7 @@ async def on_reaction_add(reaction, user):
if reaction.emoji == "🏠" and user.id != bot.user.id:
if message.author.guild_permissions.manage_guild == True:
try:
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], 'Disabled', one_result[5], one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_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])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Disabled', "Standart", "=", 'English', 0, '', 0, '')]
cursor.executemany("INSERT OR REPLACE INTO guilds VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", guild)
Expand All @@ -123,50 +123,50 @@ async def on_reaction_add(reaction, user):
if subargs != "off" and subargs != "on":
await settings_cmd(bot, discord, message, botconfig, os, platform, datetime, one_result)

async def set_embed_color(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis, embed_color):
async def set_embed_color(bot, discord, message, botconfig, os, platform, datetime, one_result, args, connection, cursor, localization, unix_time_millis, embed_color, guild_result):
subargs = args[2]

nopermerr_content = discord.Embed(title=str(localization[1][2][5][5]), description=str(localization[1][2][5][4]), color=botconfig['accent2'])
if message.author.guild_permissions.manage_guild == True:
if subargs == "red":
try:
print('test')
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], one_result[4], "Red", one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_result[11])]
guild = [(message.guild.id, one_result[1], guild_result[2], guild_result[3], guild_result[4], "Red", guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Enabled', "Red", "=", 'English', 0, '', 0, '')]
if subargs == "orange":
try:
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], one_result[4], "Standart", one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_result[11])]
guild = [(message.guild.id, one_result[1], guild_result[2], guild_result[3], guild_result[4], "Standart", guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Enabled', "Standart", "=", 'English', 0, '', 0, '')]
if subargs == "yellow":
try:
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], one_result[4], "Yellow", one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_result[11])]
guild = [(message.guild.id, one_result[1], guild_result[2], guild_result[3], guild_result[4], "Yellow", guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Enabled', "Yellow", "=", 'English', 0, '', 0, '')]
if subargs == "green":
try:
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], one_result[4], "Green", one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_result[11])]
guild = [(message.guild.id, one_result[1], guild_result[2], guild_result[3], guild_result[4], "Green", guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Enabled', "Green", "=", 'English', 0, '', 0, '')]
if subargs == "skyblue":
try:
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], one_result[4], "Sky-blue", one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_result[11])]
guild = [(message.guild.id, one_result[1], guild_result[2], guild_result[3], guild_result[4], "Sky-blue", guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Enabled', "Sky-blue", "=", 'English', 0, '', 0, '')]
if subargs == "blue":
try:
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], one_result[4], "Blue", one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_result[11])]
guild = [(message.guild.id, one_result[1], guild_result[2], guild_result[3], guild_result[4], "Blue", guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Enabled', "Blue", "=", 'English', 0, '', 0, '')]
if subargs == "violet":
try:
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], one_result[4], "Violet", one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_result[11])]
guild = [(message.guild.id, one_result[1], guild_result[2], guild_result[3], guild_result[4], "Violet", guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Enabled', "Violet", "=", 'English', 0, '', 0, '')]
if subargs == "rose":
try:
guild = [(message.guild.id, one_result[1], one_result[2], one_result[3], one_result[4], "Rose", one_result[6], one_result[7], one_result[8], one_result[9], one_result[10], one_result[11])]
guild = [(message.guild.id, one_result[1], guild_result[2], guild_result[3], guild_result[4], "Rose", guild_result[6], guild_result[7], guild_result[8], guild_result[9], guild_result[10], guild_result[11])]
except:
guild = [(message.guild.id, str(message.guild.region), 1, unix_time_millis(message.created_at), 'Enabled', "Rose", "=", 'English', 0, '', 0, '')]
try:
Expand Down
38 changes: 31 additions & 7 deletions discord_bot/d_commands/state.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
async def state_cmd(bot, discord, sqlite3, message, botconfig, os, platform, datetime, one_result, localization, embed_color, connection, cursor):
async def state_cmd(bot, discord, sqlite3, message, botconfig, os, platform, datetime, one_result, localization, embed_color, connection, cursor, cpuinfo, psutil):
data_collecting_content = discord.Embed(title=str(localization[1][1][0]), description="**" + str(localization[1][1][1]) + ":** " + str(round(bot.latency * 1000, 2)) + str(localization[1][1][2]) + "\n\n" + str(localization[1][1][18]), color=embed_color)
msg = await message.channel.send(embed=data_collecting_content)
usersdb = cursor.execute('SELECT * FROM users').rowcount
usersdb_count = cursor.fetchall()
state_content = discord.Embed(title=str(localization[1][1][0]), color=embed_color, inline=True)
state_content.add_field(name=str(localization[1][1][1]), value=str(round(bot.latency * 1000, 2)) + str(localization[1][1][2]), inline=True)
state_content.add_field(name=str(localization[1][1][3]), value=platform.uname()[0] + " " + platform.uname()[2] + " (" + platform.uname()[3] + ")", inline=True)
state_content.add_field(name=str(localization[1][1][4]), value=platform.processor(), inline=True)
guildsdb = cursor.execute('SELECT * FROM guilds').rowcount
guildsdb_count = cursor.fetchall()
if cpuinfo.get_cpu_info()['count'] < 2:
cores_amount = str(cpuinfo.get_cpu_info()['count']) + localization[1][1][9]
elif cpuinfo.get_cpu_info()['count'] < 5:
cores_amount = str(cpuinfo.get_cpu_info()['count']) + localization[1][1][10]
else:
cores_amount = str(cpuinfo.get_cpu_info()['count']) + localization[1][1][11]

if psutil.virtual_memory().available < 1024:
ram_available = str(round(psutil.virtual_memory().available / 1024, 2)) + localization[1][1][14] + localization[1][1][17]
elif psutil.virtual_memory().available < 1048576 and psutil.virtual_memory().available >= 1024:
ram_available = str(round(psutil.virtual_memory().available / 1024 / 1024, 2)) + localization[1][1][15] + localization[1][1][17]
else:
ram_available = str(round(psutil.virtual_memory().available / 1024 / 1024 / 1024, 2)) + localization[1][1][16] + localization[1][1][17]

if psutil.virtual_memory().total < 1024:
ram_total = str(round(psutil.virtual_memory().total / 1024, 2)) + localization[1][1][14]
elif psutil.virtual_memory().total < 1048576 and psutil.virtual_memory().total >= 1024:
ram_total = str(round(psutil.virtual_memory().total / 1024 / 1024, 2)) + localization[1][1][15]
else:
ram_total = str(round(psutil.virtual_memory().total / 1024 / 1024 / 1024, 2)) + localization[1][1][16]
state_content = discord.Embed(title=str(localization[1][1][0]), description="**" + str(localization[1][1][1]) + ":** " + str(round(bot.latency * 1000, 2)) + str(localization[1][1][2]), color=embed_color)
state_content.add_field(name=str(localization[1][1][3]), value=platform.uname()[0] + " " + platform.uname()[2] + " (" + platform.uname()[3] + ")", inline=False)
state_content.add_field(name=str(localization[1][1][4]), value=str(cpuinfo.get_cpu_info()['brand_raw']) + " (" + cores_amount + ", " + str(round(cpuinfo.get_cpu_info()['hz_advertised'][0] / 1000000, 2)) + localization[1][1][12] + ")", inline=False)
state_content.add_field(name=str(localization[1][1][13]), value=ram_available + " / " + ram_total, inline=True)
state_content.add_field(name=str(localization[1][1][5]), value=platform.python_version(), inline=True)
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)
await message.channel.send(embed=state_content)
state_content.add_field(name=str(localization[1][1][8]), value="🏠 " + str(len(bot.guilds)) + " | 👥 " + str(len(bot.users)) + " | 🗃 " + str(len(usersdb_count) + len(guildsdb_count)), inline=True)
await msg.edit(embed=state_content)
24 changes: 16 additions & 8 deletions discord_bot/d_languages/en_US.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def get():
' - 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` `info`' # 1.0.1.1
'`help`, `state`, `profile`, `feedback`, `info`' # 1.0.1.1
],
[ # 1.0.2
'Fun', # 1.0.2.0
'`=photo`' # 1.0.2.1
'`photo`, `8ball` (`crystball`)' # 1.0.2.1
],
[ # 1.0.3
'Management', # 1.0.3.0
'`=settings`' # 1.0.3.1
'`settings`, `post`' # 1.0.3.1
],
[ # 1.0.4
'Miscellaneous', # 1.0.4.0
Expand All @@ -38,8 +38,16 @@ def get():
'Python build date', # 1.1.6
'Packages versions', # 1.1.7
'Analytics', # 1.1.8
'Bot author', # 1.1.9
'Links' # 1.1.10
' core', # 1.1.9
' cores', # 1.1.10
' cores', # 1.1.11
' MHz', # 1.1.12
'RAM', # 1.1.13
' kB', # 1.1.14
' MB', # 1.1.15
' GB', # 1.1.16
' free', # 1.1.17
'Data collection in progress as it may take time.' # 1.1.18
],
[ # 1.2
'Settings', # 1.2.0
Expand Down Expand Up @@ -249,10 +257,10 @@ def get():
'{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
'Bots Monitorings', # 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)\n[top.gg](https://top.gg/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
'[Invite](https://discord.com/api/oauth2/authorize?client_id=785383439196487720&permissions=8&scope=bot)\n[GitHub](https://github.com/tinelix/visionbot)\n[Our support server](https://discord.gg/HAt6K2QuJU)' # 1.15.7
],
[ # 1.16
'Polling', # 1.16.0
Expand Down
Loading

0 comments on commit 686f791

Please sign in to comment.