Skip to content

Commit

Permalink
👗More renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Aluerie committed Mar 10, 2025
1 parent f3bfe51 commit 9f6d2d0
Show file tree
Hide file tree
Showing 27 changed files with 131 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "LueBot",
"name": "IreBot",
"type": "debugpy",
"request": "launch",
"program": "__main__.py",
Expand Down
9 changes: 3 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"cSpell.words": [
"Adge",
"Alue",
"aluebot",
"BOTPRACTICE",
"Chadder",
"charinfo",
Expand All @@ -28,9 +26,6 @@
"kmmrbot",
"lolrankbot",
"loremipsum",
"luebot",
"LUEBOT",
"lueloop",
"matchid",
"Mireska",
"monka",
Expand All @@ -42,6 +37,8 @@
"oconst",
"Okayge",
"partialuser",
"pcpartpicker",
"pcparts",
"POGCRAZY",
"randompasta",
"reciever",
Expand Down Expand Up @@ -73,6 +70,6 @@
],
"python.REPL.enableREPLSmartSend": false,
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:///d%3A/LAPTOP/LueBot/.github/workflows/deploy.yml"
"https://json.schemastore.org/github-workflow.json": "file:///d%3A/LAPTOP/IreBot/.github/workflows/deploy.yml"
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Just a personal bot of mine ([@Irene_Adler__](https://www.twitch.tv/irene_adler_

> ![IreBot Display Name](<assets/images/display_name.png>)
1. [🏠 Wiki](https://github.com/Aluerie/LueBot/wiki) - link to github wiki page, most notably:
* [🛠️ Running/Installation guide](https://github.com/Aluerie/LueBot/wiki/%F0%9F%9B%A0%EF%B8%8FRunning-Installation-guide)
1. [🏠 Wiki](https://github.com/Aluerie/IreBot/wiki) - link to github wiki page, most notably:
* [🛠️ Running/Installation guide](https://github.com/Aluerie/IreBot/wiki/%F0%9F%9B%A0%EF%B8%8FRunning-Installation-guide)
4 changes: 2 additions & 2 deletions __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ async def start_the_bot() -> None:
async with (
aiohttp.ClientSession() as session,
pool as pool,
IreBot(session=session, pool=pool) as luebot,
IreBot(session=session, pool=pool) as irebot,
):
await luebot.start()
await irebot.start()


@click.group(invoke_without_command=True, options_metavar="[options]")
Expand Down
2 changes: 1 addition & 1 deletion bot/bases/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


class IreComponent(commands.Component):
"""Base component to use with LueBot."""
"""Base component to use with IreBot."""

def __init__(self, bot: IreBot) -> None:
self.bot: IreBot = bot
Expand Down
44 changes: 22 additions & 22 deletions bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(
session: ClientSession,
pool: asyncpg.Pool[asyncpg.Record],
) -> None:
"""Initiate LueBot."""
"""Initiate IreBot."""
self.prefixes: tuple[str, ...] = ("!", "?", "$")
# adapter: StarletteAdapter = StarletteAdapter(
# host="0.0.0.0",
Expand All @@ -96,26 +96,6 @@ def __init__(

self.irene_online: bool = False

# def show_oauth(self) -> None:
# oauth = twitchio.authentication.OAuth(
# client_id=config.TTV_DEV_CLIENT_ID,
# client_secret=config.TTV_DEV_CLIENT_SECRET,
# redirect_uri="http://localhost:4343/oauth/callback",
# scopes=twitchio.Scopes(
# [
# "channel:bot",
# "channel:read:ads",
# "channel:moderate",
# "moderator:read:followers",
# "channel:read:redemptions",
# ]
# ),
# )
# #
# # # Generate the authorization URL
# auth_url = oauth.get_authorization_url(force_verify=True)
# print(auth_url) # noa: T201

def print_bot_oauth(self) -> None:
"""Print a link for me (developer) to click and authorize the bot scopes for the bot account.
Expand Down Expand Up @@ -309,7 +289,7 @@ async def event_command_error(self, payload: commands.CommandErrorPayload) -> No
error = error.original if isinstance(error, commands.CommandInvokeError) and error.original else error

match error:
case errors.LueBotError():
case errors.IreBotError():
# errors defined by me - just send the string
await ctx.send(str(error))
case commands.CommandNotFound():
Expand Down Expand Up @@ -433,3 +413,23 @@ async def event_stream_offline(self, _: twitchio.StreamOffline) -> None:
"""Instead of the twitchio event - dispatch my own offline event."""
self.irene_online = False
self.dispatch("aluerie_offline")

# def show_oauth(self) -> None:
# oauth = twitchio.authentication.OAuth(
# client_id=config.TTV_DEV_CLIENT_ID,
# client_secret=config.TTV_DEV_CLIENT_SECRET,
# redirect_uri="http://localhost:4343/oauth/callback",
# scopes=twitchio.Scopes(
# [
# "channel:bot",
# "channel:read:ads",
# "channel:moderate",
# "moderator:read:followers",
# "channel:read:redemptions",
# ]
# ),
# )
# #
# # # Generate the authorization URL
# auth_url = oauth.get_authorization_url(force_verify=True)
# print(auth_url) # noa: T201
2 changes: 1 addition & 1 deletion bot/exc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def register_error(self, error: BaseException, embed: discord.Embed, *, me
"""Register, analyse error and put it into queue to send to developers."""
log.error("%s: `%s`.", error.__class__.__name__, embed.footer.text, exc_info=error)

traceback_string = "".join(traceback.format_exception(error)).replace(str(Path.cwd()), "LueBot")
traceback_string = "".join(traceback.format_exception(error)).replace(str(Path.cwd()), "IreBot")

async with self._lock:
if self._most_recent and (delta := datetime.datetime.now(datetime.UTC) - self._most_recent) < self.cooldown:
Expand Down
29 changes: 15 additions & 14 deletions bot/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

# generated at https://patorjk.com/software/taag/ using "Standard" font
ASCII_STARTING_UP_ART = r"""
_ ____ _ ____ _ _ _
| | _ _ ___| __ ) ___ | |_ / ___|| |_ __ _ _ __| |_(_)_ __ __ _
| | | | | |/ _ \ _ \ / _ \| __| \___ \| __/ _` | '__| __| | '_ \ / _` |
| |__| |_| | __/ |_) | (_) | |_ ___) | || (_| | | | |_| | | | | (_| |
|_____\__,_|\___|____/ \___/ \__| |____/ \__\__,_|_| \__|_|_| |_|\__, |
|___/
[ LUEBOT IS STARTING NOW ]
___ ____ _____ ____ ___ _____ ____ _____ _ ____ _____ ___ _ _ ____
|_ _| _ \| ____| __ ) / _ \_ _| / ___|_ _|/ \ | _ \_ _|_ _| \ | |/ ___|
| || |_) | _| | _ \| | | || | \___ \ | | / _ \ | |_) || | | || \| | | _
| || _ <| |___| |_) | |_| || | ___) || |/ ___ \| _ < | | | || |\ | |_| |
|___|_| \_\_____|____/ \___/ |_| |____/ |_/_/ \_\_| \_\|_| |___|_| \_|\____
[ IREBOT IS STARTING NOW ]
"""


Expand All @@ -42,7 +41,7 @@ def setup_logging() -> Generator[Any, Any, Any]:
Path(".temp/").mkdir(parents=True, exist_ok=True)
# File Handler
file_handler = RotatingFileHandler(
filename=".temp/luebot.log",
filename=".temp/irebot.log",
encoding="utf-8",
mode="w",
maxBytes=24 * 1024 * 1024, # MiB
Expand Down Expand Up @@ -81,7 +80,7 @@ class MyColourFormatter(logging.Formatter):
# 100-107 are the same as the bright ones but for the background.
# 1 means bold, 2 means dim, 0 means reset, and 4 means underline.

LEVEL_COLOURS = (
LEVEL_COLORS = (
(logging.DEBUG, "\x1b[40;1m"),
(logging.INFO, "\x1b[34;1m"),
(logging.WARNING, "\x1b[33;1m"),
Expand All @@ -91,11 +90,13 @@ class MyColourFormatter(logging.Formatter):

FORMATS: ClassVar[dict[int, logging.Formatter]] = {
level: logging.Formatter(
f"\x1b[37;1m%(asctime)s\x1b[0m | {colour}%(levelname)-7s\x1b[0m | "
f"\x1b[35m%(name)-30s\x1b[0m | %(lineno)-4d | %(funcName)-30s | %(message)s",
"%H:%M:%S %d/%m",
(
f"\x1b[37;1m%(asctime)s\x1b[0m {color}%(levelname)-4.4s\x1b[0m "
"\x1b[35m%(name)-30s\x1b[0m \x1b[92m%(lineno)-4d\x1b[0m \x1b[36m%(funcName)-35s\x1b[0m %(message)s"
),
"%H:%M:%S", # note there is no "%d/%m" because I'm saving those 6 characters :D
)
for level, colour in LEVEL_COLOURS
for level, color in LEVEL_COLORS
}

@override
Expand Down Expand Up @@ -125,7 +126,7 @@ def get_log_fmt(handler: logging.Handler) -> logging.Formatter:
formatter = MyColourFormatter()
else:
formatter = logging.Formatter(
"{asctime} | {levelname:<7} | {name:<23} | {lineno:<4} | {funcName:<30} | {message}",
"%(asctime)s %(levelname)-4.4s %(name)-30s %(lineno)-4d %(funcName)-35s %(message)s",
"%H:%M:%S %d/%m",
style="{",
)
Expand Down
2 changes: 1 addition & 1 deletion examples/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ async def new_command(self, ctx: commands.Context) -> None:


async def setup(bot: IreBot) -> None:
"""Load LueBot extension. Framework of twitchio."""
"""Load IreBot extension. Framework of twitchio."""
await bot.add_component(NewCog(bot))
9 changes: 4 additions & 5 deletions ext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__all__ = ("EXTENSIONS",)

try:
import _test
import _test # noqa: PLC2701

TEST_EXTENSIONS = _test.TEST_EXTENSIONS
TEST_USE_ALL_EXTENSIONS = _test.TEST_USE_ALL_EXTENSIONS
Expand Down Expand Up @@ -34,13 +34,12 @@ def get_extensions() -> tuple[str, ...]:
if platform.system() == "Windows" and not TEST_USE_ALL_EXTENSIONS:
# assume testing specific extensions from `_test.py`
return tuple(f"{__package__}.{ext}" for ext in TEST_EXTENSIONS)
# assume running full bot functionality (besides `DISABLED_EXTENSIONS`)

# assume running full bot functionality (besides `DISABLED_EXTENSIONS`)
all_extensions = tuple(
module.name
for module in iter_modules(__path__, f"{__package__}.")
if module.name not in DISABLED_EXTENSIONS
module.name for module in iter_modules(__path__, f"{__package__}.") if module.name not in DISABLED_EXTENSIONS
)
# move CORE_EXTENSIONS to the front
temp = tuple(set(all_extensions).difference(CORE_EXTENSIONS))
return CORE_EXTENSIONS + temp

Expand Down
2 changes: 1 addition & 1 deletion ext/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,5 @@ async def subscription(self, subscribe: twitchio.ChannelSubscribe) -> None:


async def setup(bot: IreBot) -> None:
"""Load LueBot extension. Framework of twitchio."""
"""Load IreBot extension. Framework of twitchio."""
await bot.add_component(Alerts(bot))
2 changes: 1 addition & 1 deletion ext/counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,5 @@ async def check_first_reward(self) -> None:


async def setup(bot: IreBot) -> None:
"""Load LueBot extension. Framework of twitchio."""
"""Load IreBot extension. Framework of twitchio."""
await bot.add_component(Counters(bot))
2 changes: 1 addition & 1 deletion ext/custom_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@ async def cmd_list(self, ctx: commands.Context) -> None:


async def setup(bot: IreBot) -> None:
"""Load LueBot extension. Framework of twitchio."""
"""Load IreBot extension. Framework of twitchio."""
await bot.add_component(CustomCommands(bot))
6 changes: 3 additions & 3 deletions ext/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def maintenance(self, ctx: commands.Context) -> None:
await ctx.send("Shutting down the bot in 3 2 1")
await asyncio.sleep(3)
try:
await asyncio.create_subprocess_shell("sudo systemctl stop luebot") # `os.system`
await asyncio.create_subprocess_shell("sudo systemctl stop irebot") # `os.system`
except Exception:
log.exception("Failed to Stop the bot's process", stack_info=True)
# it might not go off
Expand All @@ -54,7 +54,7 @@ async def reboot(self, ctx: commands.Context) -> None:
await asyncio.sleep(3)
try:
# non systemctl users - sorry
await asyncio.create_subprocess_shell("sudo systemctl restart luebot") # `os.system`
await asyncio.create_subprocess_shell("sudo systemctl restart irebot") # `os.system`
except Exception:
log.exception("Failed to Restart the bot's process", stack_info=True)
# it might not go off
Expand Down Expand Up @@ -100,5 +100,5 @@ async def offline(self, ctx: commands.Context) -> None:


async def setup(bot: IreBot) -> None:
"""Load LueBot extension. Framework of twitchio."""
"""Load IreBot extension. Framework of twitchio."""
await bot.add_component(Development(bot))
2 changes: 1 addition & 1 deletion ext/dota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@


async def setup(bot: IreBot) -> None:
"""Load LueBot extension. Framework of twitchio."""
"""Load IreBot extension. Framework of twitchio."""
await bot.add_component(DotaCommands(bot))
10 changes: 2 additions & 8 deletions ext/dota/api/dota2client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@
from steam import PersonaState
from steam.ext.dota2 import Client

try:
import config
except ImportError:
import sys

sys.path.append("D:/LAPTOP/LueBot")
import config
import config

from .pulsefire_clients import SteamWebAPIClient, StratzClient
from .storage import Items
Expand Down Expand Up @@ -42,7 +36,7 @@ def __init__(self, twitch_bot: IreBot) -> None:
self.stratz = StratzClient()
self.items = Items(twitch_bot)

def aluerie(self) -> PartialUser:
def irene(self) -> PartialUser:
return self.instantiate_partial_user(config.IRENE_STEAM_ID64)

async def start_helpers(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion ext/dota/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async def double_check_task(self) -> None:
@clean_up_the_database.before_loop
@check_streamers_rich_presence.before_loop
async def before_check_streamers_rich_presence(self) -> None:
"""Wait for the LueBot, Dota Client and Game Coordinator ready-s."""
"""Wait for the IreBot, Dota Client and Game Coordinator ready-s."""
await self.bot.wait_until_ready()
await self.bot.dota.wait_until_ready()
await self.bot.dota.wait_until_gc_ready()
13 changes: 6 additions & 7 deletions ext/emotes_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def send_error_embed(self, emote: str, service: str, colour: int) -> None:
title=f"Problem with {service} emotes",
description=f"Looks like emote `{emote}` is no longer present in the channel.",
colour=colour,
).set_footer(text="but it was previously used for @AlueBot emotes")
).set_footer(text="but it was previously used for @IreBot emotes")
await self.bot.error_webhook.send(content=content, embed=embed)

async def cross_check_emotes(self, api_emotes: list[str], bot_emotes: type[StrEnum], colour: int) -> None:
Expand All @@ -55,27 +55,26 @@ async def check_emotes(self) -> None:
# simple way to make a task run once/week
return

broadcaster_id = const.UserID.Irene
# SEVEN TV
async with self.bot.session.get(f"https://7tv.io/v3/users/twitch/{const.UserID.Irene}") as resp:
async with self.bot.session.get(f"https://7tv.io/v3/users/twitch/{broadcaster_id}") as resp:
stv_json = await resp.json()
stv_emote_list = [emote["name"] for emote in stv_json["emote_set"]["emotes"]]
await self.cross_check_emotes(stv_emote_list, const.STV, 0x3493EE)

# FFZ
async with self.bot.session.get(f"https://api.frankerfacez.com/v1/room/id/{const.UserID.Irene}") as resp:
async with self.bot.session.get(f"https://api.frankerfacez.com/v1/room/id/{broadcaster_id}") as resp:
ffz_json = await resp.json() # if we ever need this "654554" then it exists as `ffz_json["room"]["set"]`
ffz_emote_list = [emote["name"] for emote in ffz_json["sets"]["654554"]["emoticons"]]
await self.cross_check_emotes(ffz_emote_list, const.FFZ, 0x271F3E)

# BTTV
async with self.bot.session.get(
f"https://api.betterttv.net/3/cached/users/twitch/{const.UserID.Irene}",
) as resp:
async with self.bot.session.get(f"https://api.betterttv.net/3/cached/users/twitch/{broadcaster_id}") as resp:
bttv_json = await resp.json()
bttv_emote_list = [emote["code"] for emote in bttv_json["channelEmotes"] + bttv_json["sharedEmotes"]]
await self.cross_check_emotes(bttv_emote_list, const.BTTV, 0xD50014)


async def setup(bot: IreBot) -> None:
"""Load LueBot extension. Framework of twitchio."""
"""Load IreBot extension. Framework of twitchio."""
await bot.add_component(EmoteChecker(bot))
2 changes: 1 addition & 1 deletion ext/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ async def keywords_response(self, message: twitchio.ChatMessage) -> None:


async def setup(bot: IreBot) -> None:
"""Load LueBot extension. Framework of twitchio."""
"""Load IreBot extension. Framework of twitchio."""
await bot.add_component(Keywords(bot))
2 changes: 1 addition & 1 deletion ext/logs_via_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def logging_worker(self) -> None:


async def setup(bot: IreBot) -> None:
"""Load LueBot extension. Framework of twitchio."""
"""Load IreBot extension. Framework of twitchio."""
if __name__ in bot.extensions:
# check if the extension is listed in extensions

Expand Down
Loading

0 comments on commit 9f6d2d0

Please sign in to comment.