Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unused imports #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions cogs/skyfun.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\
# \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/
#
#
# AGPL-3.0 license

import random
import string

import discord
from discord.ext import commands as skySB
import utils


class Fun(skySB.Cog):
def __init__(self, bot):
self.bot = bot
self.langpack = utils.Langs.getcurrent()['fun']

@skySB.command(
description=utils.Langs.getcurrent()['fun']['dick']['description']
)
Expand All @@ -26,10 +26,10 @@ async def dick(self, ctx, user: discord.User = None):
mention = user.mention
else:
mention = self.bot.user

size = random.randint(1, 1000)
await utils.answer(
ctx,
ctx,
self.langpack['dick']['text'].format(mention, size))

@skySB.command(
Expand All @@ -40,12 +40,12 @@ async def iq(self, ctx, user: discord.User = None):
mention = user.mention
else:
mention = self.bot.user

iq = random.randint(1, 1000)
await utils.answer(
ctx,
ctx,
self.langpack['iq']['text'].format(mention, iq))

@skySB.command(
description=utils.Langs.getcurrent()['fun']['gay']['description']
)
Expand All @@ -54,11 +54,12 @@ async def gay(self, ctx, user: discord.User = None):
mention = user.mention
else:
mention = self.bot.user

percent = random.randint(0, 101)
await utils.answer(
ctx,
ctx,
self.langpack['gay']['text'].format(mention, percent))



async def setup(bot):
await bot.add_cog(Fun(bot))
await bot.add_cog(Fun(bot))
15 changes: 7 additions & 8 deletions skySB.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\
# \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/
#
#
# AGPL-3.0 license

import os

import discord
from utils import config, motd, bot, logger
from colored import Fore, Style

print(motd)
logger.warning(f'status: {Fore.YELLOW}loading...{Style.RESET}')


@bot.event
async def on_ready():
os.system('clear')
Expand All @@ -23,7 +22,7 @@ async def on_ready():
logger.warning(f'connected: {Style.BOLD}{bot.user}{Style.RESET}')
logger.warning(f'prefix: {Style.BOLD}{config.get("prefix")}{Style.RESET}')
print("-" * 45)

for file in os.listdir(f"{os.path.realpath(os.path.dirname(__file__))}/cogs"):
if file.startswith("_"):
pass
Expand All @@ -36,4 +35,4 @@ async def on_ready():
logger.error(f'{extension}: {exception}')

while True:
bot.run(config.get('token'), log_handler=None)
bot.run(config.get('token'), log_handler=None)
53 changes: 28 additions & 25 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\
# \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/
#
#
# AGPL-3.0 license

import json
import logging
import asyncio
import os
import io

import discord
from discord.ext import commands

from colored import Fore, Style
from types import FunctionType

# Logging
logging.basicConfig(format=f"%(asctime)s | [{Fore.CYAN}%(levelname)s{Style.RESET}] %(message)s", level=logging.WARNING, datefmt='%H:%M')
logging.basicConfig(
format=f"%(asctime)s | [{Fore.CYAN}%(levelname)s{Style.RESET}] %(message)s", level=logging.WARNING, datefmt='%H:%M')
logger = logging.getLogger(__name__)


Expand All @@ -34,44 +31,46 @@
)
bot.remove_command('help')


class Langs:
@staticmethod
def all() -> list:
"""
Get all langpacks

Returns:
List - list all langpacks in directory.
"""
return os.listdir('./langs/')

@staticmethod
def getcurrent() -> dict:
"""
Get current langpack

Returns:
Dict - langpack JSON data
"""
with open(config.get('language')) as f:
langpack = json.load(f)
return langpack

@staticmethod
def get(file: str) -> dict:
"""
Get langpack

Parameters:
file (String) - file path
Returns:
Dict - langpack JSON data
"""
with open(file) as f:
langpack = json.load(f)

return langpack


# MOTD
motd = """
______ __ __ __ __ ______ ______
Expand All @@ -81,20 +80,21 @@ def get(file: str) -> dict:
\/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/
"""


async def answer(
ctx,
ctx,
message: str,
photo: bool = False,
document: bool = False,
**kwargs
) -> str:
"""
Answer text

Parameters:
ctx (Content),
message (String)

Returns:
String - message text
"""
Expand All @@ -108,19 +108,20 @@ async def answer(
responses.append(await ctx.message.edit(message))
except:
responses.append(await ctx.reply(message))

await asyncio.sleep(config.get('deletetimer'))

for response in responses:
await response.delete()
return responses


def get_ram() -> float:
"""
! from teagram

Get your ram usage

Returns:
Float - ram usage
"""
Expand All @@ -134,10 +135,11 @@ def get_ram() -> float:
except:
return 0


def get_cpu() -> float:
"""
! from teagram

Get CPU usage as a percentage

Returns:
Expand All @@ -157,10 +159,11 @@ def get_cpu() -> float:
except:
return 0


def get_platform() -> str:
"""
! from teagram

Get the platform information

Returns:
Expand Down Expand Up @@ -190,4 +193,4 @@ def get_platform() -> str:
elif IS_ZACHOST:
return "❔ Zachem㉿Host"
else:
return "🖥️ VDS"
return "🖥️ VDS"