Files
Moon-UB-overver/utils/misc.py
AbhiTheModder 3e8520b0f5 refactor
2023-02-09 11:55:47 +05:30

46 lines
1.5 KiB
Python

# Moon-Userbot - telegram userbot
# Copyright (C) 2020-present Moon Userbot Organization
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from sys import version_info
from .db import db
from git import Repo
class ModulesHelpDict(dict):
def append(self, obj: dict):
# convert help from old to new type
module_name = list(obj.keys())[0]
cmds = obj[module_name]
commands = {}
for cmd in cmds:
cmd_name = list(cmd.keys())[0]
cmd_desc = cmd[cmd_name]
commands[cmd_name] = cmd_desc
self[module_name] = commands
modules_help = ModulesHelpDict()
requirements_list = []
python_version = f"{version_info[0]}.{version_info[1]}.{version_info[2]}"
prefix = db.get("core.main", "prefix", ".")
gitrepo = Repo(".")
commits_since_tag = list(gitrepo.iter_commits(
f"{gitrepo.tags[-1].name}..HEAD"))
userbot_version = f"3.1.{len(commits_since_tag)}"