This repository has been archived by the owner on Jul 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit - April 17, 2021 (01A1-VK-210417, Alpha)
- Loading branch information
Showing
6 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
def localize(): | ||
return { | ||
'language': 'Russian', | ||
'Start': { | ||
'commands': { | ||
'001': 'Начать', | ||
'002': 'Старт' | ||
}, | ||
'message': 'Здравствуйте. Портированная версия бота {0} для ВКонтакте находится в стадии разработки.\n\nНо не переживайте, открытие бота запланировано на 30 апреля 2021 г. А пока воспользуйтесь готовыми фишками, нажав на соответствущую кнопку.', | ||
'keyboard': { | ||
'001': 'О боте', | ||
'002': 'О пользователе', | ||
'003': 'О беседе', | ||
'004': 'Еще >>' | ||
} | ||
}, | ||
'Bot information': { | ||
'commands': { | ||
'001': 'О боте', | ||
'002': 'Системная инфа' | ||
}, | ||
'message': 'ℹ Информация о боте\n\nПод управлением: {0} ({1})\nЦП: {2} ({3}, {4} МГц)\nВерсия Python: {5}\nДата сборки Python: {6}\nВерсия бота: {7}\nАналитика: 💬 {8}', | ||
'core_units': { | ||
'001': ' ядро', | ||
'002': ' ядра', | ||
'003': ' ядер' | ||
}, | ||
'keyboard': { | ||
'001': 'Список команд' | ||
} | ||
}, | ||
'Commands list': { | ||
'message': '📄 Список команд\n\n"О боте" - просмотр системной информации, на чем запущен бот\n\nВсе остальные команды на данный момент не реализованы, но будут разрабатываться.' | ||
}, | ||
'Under construction': { | ||
'commands': { | ||
'001': 'Список команд' | ||
}, | ||
'message': 'Эта функция на данный момент не реализована и в дальнейшем будет разрабатываться.' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import vk.bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import requests | ||
import vk_api | ||
import random | ||
import cpuinfo | ||
import psutil | ||
import os | ||
import platform | ||
|
||
import vk.commands.start as start_cmd | ||
import vk.commands.bot_info as bot_info_cmd | ||
|
||
import vk.languages.ru_RU as ru_RU | ||
localization = ru_RU.localize() | ||
|
||
from vk.botconfig import botconfig | ||
|
||
vk_session = vk_api.VkApi(token=botconfig['token']) | ||
|
||
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType | ||
from vk_api.keyboard import VkKeyboard, VkKeyboardColor | ||
from vk_api.utils import get_random_id | ||
|
||
longpoll = VkBotLongPoll(vk_session, '202978127') | ||
vk = vk_session.get_api() | ||
print('VK Bot API connected!') | ||
|
||
for event in longpoll.listen(): | ||
if event.type == VkBotEventType.MESSAGE_NEW: | ||
try: | ||
if event.message.text == localization['Start']['commands']['001'] or event.message.text == localization['Start']['commands']['002']: | ||
start_cmd.push(botconfig, event, localization, vk, VkKeyboard, VkKeyboardColor, get_random_id) | ||
if event.message.text == localization['Bot information']['commands']['001'] or event.message.text == localization['Bot information']['commands']['002']: | ||
bot_info_cmd.push(botconfig, event, localization, vk, VkKeyboard, VkKeyboardColor, cpuinfo, psutil, os, platform, get_random_id) | ||
except e as Exception: | ||
print(e) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
from dotenv import load_dotenv | ||
dotenv_path = os.path.join('../', '.env') | ||
if os.path.exists(dotenv_path): | ||
load_dotenv(dotenv_path) | ||
|
||
botconfig = { | ||
'token': os.environ['VKTOKEN'], | ||
'name': 'VisionOne', | ||
'id': 785383439196487720, | ||
'prefix': '=', | ||
'accent1': 0xd7832a, | ||
'accent2': 0xcb3532, | ||
'accent3': 0x6eda5f, | ||
'version': '01A1-VK-210417', | ||
'owner': '741883312108339231', | ||
'logs_channel': 788723868255649832, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
def push(botconfig, event, localization, vk, VkKeyboard, VkKeyboardColor, cpuinfo, psutil, os, platform, get_random_id): | ||
keyboard = VkKeyboard(one_time=True) | ||
keyboard.add_button(localization['Bot information']['keyboard']['001'], color=VkKeyboardColor.PRIMARY) | ||
|
||
if cpuinfo.get_cpu_info()['count'] < 2: | ||
cores_amount = str(cpuinfo.get_cpu_info()['count']) + localization['Bot information']['core_units']['001'] | ||
elif cpuinfo.get_cpu_info()['count'] < 5: | ||
cores_amount = str(cpuinfo.get_cpu_info()['count']) + localization['Bot information']['core_units']['002'] | ||
else: | ||
cores_amount = str(cpuinfo.get_cpu_info()['count']) + localization['Bot information']['core_units']['003'] | ||
|
||
if event.from_user: | ||
vk.messages.send( | ||
random_id=0, | ||
peer_id=event.message.peer_id, | ||
message=localization['Bot information']['message'].format(platform.uname()[0] + " " + platform.uname()[2], platform.uname()[3], str(cpuinfo.get_cpu_info()['brand_raw']), cores_amount, str(round(cpuinfo.get_cpu_info()['hz_advertised'][0] / 1000000, 2)), platform.python_version(), platform.python_build()[1], botconfig['version'], '(в разработке)'), | ||
keyboard=keyboard.get_keyboard() | ||
) | ||
elif event.from_chat: | ||
vk.messages.send( | ||
peer_id=event.message.peer_id, | ||
random_id=get_random_id(), | ||
message=localization['Bot information']['message'].format(botconfig['name']), | ||
keyboard=keyboard.get_keyboard() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
def push(botconfig, event, localization, vk, VkKeyboard, VkKeyboardColor, get_random_id): | ||
keyboard = VkKeyboard(one_time=True) | ||
keyboard.add_button(localization['Start']['keyboard']['001'], color=VkKeyboardColor.PRIMARY) | ||
keyboard.add_button(localization['Start']['keyboard']['002'], color=VkKeyboardColor.SECONDARY) | ||
|
||
keyboard.add_line() | ||
|
||
if event.from_chat: | ||
keyboard.add_button(localization['Start']['keyboard']['003'], color=VkKeyboardColor.SECONDARY) | ||
|
||
keyboard.add_button(localization['Start']['keyboard']['004'], color=VkKeyboardColor.SECONDARY) | ||
|
||
if event.from_user: | ||
vk.messages.send( | ||
random_id=0, | ||
peer_id=event.message.peer_id, | ||
message=localization['Start']['message'].format(botconfig['name']), | ||
keyboard=keyboard.get_keyboard() | ||
) | ||
elif event.from_chat: | ||
vk.messages.send( | ||
peer_id=event.message.peer_id, | ||
random_id=get_random_id(), | ||
message=localization['Start']['message'].format(botconfig['name']), | ||
keyboard=keyboard.get_keyboard() | ||
) |