Browse Source

Добавлены аддоны, обновлён README

dev
cofob 10 months ago
parent
commit
db63a30458
No known key found for this signature in database GPG Key ID: 9FFD2837DF98628F
  1. 2
      README.md
  2. 11
      addons/drp/customdrp/__init__.py
  3. 11
      addons/drp/livemode/__init__.py
  4. 11
      addons/status/customstatus/__init__.py
  5. 12
      api.py
  6. 0
      errors.py
  7. 47
      funcs.py
  8. 44
      main.py

2
README.md

@ -46,7 +46,7 @@
# Подпись
Все исполняемые файлы подписаны этим `9FFD2837DF98628F` PGP ключом
`9FFD2837DF98628F` PGP ключ
```
-----BEGIN PGP PUBLIC KEY BLOCK-----

11
addons/drp/customdrp/__init__.py

@ -0,0 +1,11 @@
from api import *
class Addon(BaseDRPAddon):
class Meta(BaseDRPAddon.Meta):
name = 'Custom DRP'
description = 'Аддон для смены Discord Rich Presence'
version = '0.0.1'
def __init__(self):
pass

11
addons/drp/livemode/__init__.py

@ -0,0 +1,11 @@
from api import *
class Addon(BaseDRPAddon):
class Meta(BaseDRPAddon.Meta):
name = 'Live Mode'
description = 'Аддон для отображения текущего активного окна в Windows'
version = '0.0.1'
def __init__(self):
pass

11
addons/status/customstatus/__init__.py

@ -0,0 +1,11 @@
from api import *
class Addon(BaseStatusAddon):
class Meta(BaseStatusAddon.Meta):
name = 'Custom Status'
description = 'Аддон для установки анимированного статуса'
version = '0.0.1'
def __init__(self):
pass

12
api.py

@ -0,0 +1,12 @@
class BaseDRPAddon:
class Meta:
name = 'BaseDRPAddon'
description = 'BaseDRPAddon description'
version = '0.0.1'
class BaseStatusAddon:
class Meta:
name = 'BaseStatusAddon'
description = 'BaseStatusAddon description'
version = '0.0.1'

0
errors.py

47
funcs.py

@ -0,0 +1,47 @@
import os
import importlib.util
def check_module(module_name):
module_spec = importlib.util.find_spec(module_name)
if module_spec is None:
print('Module: {} not found'.format(module_name))
return None
else:
return module_spec
def import_module_from_spec(module_spec):
module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
return module
def import_module(module):
module_spec = check_module(module)
if module_spec is not None:
return import_module_from_spec(module_spec)
def get_path(args):
if len(args) == 0:
raise AttributeError
if len(args) == 1:
return args[0]
path = args[0]
for i in args[1:]:
path = os.path.join(path, i)
return path
def mkdir(*args):
path = get_path(args)
if not os.path.isdir(path):
os.mkdir(path)
def mkfile(*args):
path = get_path(args)
if not os.path.isfile(path):
f = open(path, 'w')
f.close()

44
main.py

@ -1 +1,43 @@
import discord_rpc
import importlib
import os
from funcs import *
import api
# create dirs and files
mkdir('addons')
mkdir('addons', 'drp')
mkdir('addons', 'status')
# drp addons import
drp_addon_modules = []
for name in os.listdir(os.path.join('addons', 'drp')):
if name in ['__pycache__']:
continue
m = import_module('addons.drp.'+name)
if m is not None:
drp_addon_modules.append(m)
drp_addons = []
for addon in drp_addon_modules:
drp_addons.append(addon.Addon())
del drp_addon_modules
for addon in drp_addons:
print(f'Loaded DRP Addon -> \n\tname -> {addon.Meta.name}\n\tdescription -> {addon.Meta.description}\n\t'
f'version -> {addon.Meta.version}\n')
# status addons import
status_addon_modules = []
for name in os.listdir(os.path.join('addons', 'status')):
if name in ['__pycache__']:
continue
m = import_module('addons.status.'+name)
if m is not None:
status_addon_modules.append(m)
status_addons = []
for addon in status_addon_modules:
status_addons.append(addon.Addon())
del status_addon_modules
for addon in status_addons:
print(f'Loaded Status Addon -> \n\tname -> {addon.Meta.name}\n\tdescription -> {addon.Meta.description}\n\t'
f'version -> {addon.Meta.version}\n')