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

CI tagging #144

Merged
merged 9 commits into from
Sep 25, 2024
Merged
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
19 changes: 14 additions & 5 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ name: Docker
on:
workflow_dispatch:
push:
branches: [ master ]
branches:
- "master"
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
tags:
- "v*"
pull_request:
branches:
- "master"
- "dev"
tags:
- "v*"

env:
REGISTRY: ghcr.io
Expand All @@ -27,22 +35,23 @@ jobs:
uses: actions/checkout@v4

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}


- uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
Expand Down
6 changes: 2 additions & 4 deletions fred/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

from dotenv import load_dotenv

load_dotenv()

logging.root = logging.getLogger("FRED")
logging.basicConfig(level=getenv("FRED_LOG_LEVEL", logging.DEBUG))

from .fred import __version__ # noqa

logging.root.debug(f"HELLO WORLD!!! FRED version: {__version__}")

ENVVARS = (
"FRED_IP",
"FRED_PORT",
Expand All @@ -22,8 +22,6 @@
# "DIALOGFLOW_AUTH",
)

load_dotenv()

for var in ENVVARS:
if getenv(var) is None:
raise EnvironmentError(f"The ENV variable '{var}' isn't set")
3 changes: 3 additions & 0 deletions fred/cogs/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ async def on_member_join(self, member: Member):

self.logger.info("Processing a member joining", extra=common.user_info(member))

await self.send_welcome_message(member)

async def send_welcome_message(self, member: Member):
if welcome := config.Misc.fetch("welcome_message"):
self.logger.info("Sending the welcome message to a new member", extra=common.user_info(member))
await self.bot.send_DM(member, welcome)
Expand Down
10 changes: 8 additions & 2 deletions fred/fred.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
import traceback
from concurrent.futures import ThreadPoolExecutor
from importlib.metadata import version
from os import getenv
from typing import Optional

Expand All @@ -18,7 +19,7 @@
from .fred_commands import Commands, FredHelpEmbed
from .libraries import createembed, common

__version__ = "2.22.7"
__version__ = version("fred")


class Bot(commands.Bot):
Expand All @@ -40,10 +41,11 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.isReady = False
self.logger = common.new_logger(self.__class__.__name__)
self.version = __version__
self.logger.info(f"Starting Fred v{self.version}")
self.setup_DB()
self.command_prefix = config.Misc.fetch("prefix")
self.setup_cogs()
self.version = __version__
FredHelpEmbed.setup()
self.owo = False
self.web_session: aiohttp.ClientSession = ...
Expand Down Expand Up @@ -118,6 +120,10 @@ def Crashes(self) -> crashes.Crashes:
def DialogFlow(self) -> dialogflow.DialogFlow:
return self.get_cog("DialogFlow") # noqa

@property
def Welcome(self) -> welcome.Welcome:
return self.get_cog("Welcome") # noqa

async def on_error(self, event_method: str, *args, **kwargs):
exc_type, value, tb = sys.exc_info()
if event_method == "on_message":
Expand Down
1 change: 0 additions & 1 deletion fred/fred_commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import nextcord
from algoliasearch.search_client import SearchClient
from nextcord import Attachment
from nextcord.ext.commands.view import StringView

from ._baseclass import BaseCmds, common, config, commands
Expand Down
10 changes: 10 additions & 0 deletions fred/fred_commands/_baseclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ async def modify(self, ctx: commands.Context):
await self.bot.reply_to_msg(ctx.message, "Invalid sub command passed...")
return

@commands.group()
@commands.check(common.l4_only)
async def get(self, ctx: commands.Context):
"""Usage: `get (subcommand) [args]`
Purpose: Gets something (duh). Check individual subcommands for specifics.
Notes: Limited to permission level 4 and above."""
if ctx.invoked_subcommand is None:
await self.bot.reply_to_msg(ctx.message, "Invalid sub command passed...")
return


class SearchFlags(commands.FlagConverter, delimiter="=", prefix="-"):
column: str = "name"
Expand Down
15 changes: 14 additions & 1 deletion fred/fred_commands/bot_meta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from ._baseclass import BaseCmds, commands, config, common

if TYPE_CHECKING:
from ..fred import Bot


class BotCmds(BaseCmds):

Expand Down Expand Up @@ -34,6 +41,11 @@ async def set_latest_info(self, ctx: commands.Context, latest_info: str):
config.Misc.change("latest_info", latest_info)
await self.bot.reply_to_msg(ctx.message, "The latest info message has been changed!")

@BaseCmds.get.command(name="welcome")
async def get_welcome(self, ctx: commands.Context):
bot: Bot = ctx.bot
await bot.Welcome.send_welcome_message(ctx.author)

@commands.check(common.mod_only)
@BaseCmds.set.command(name="main_guild")
async def set_main_guild(self, ctx: commands.Context, guild_id: int = None):
Expand All @@ -56,10 +68,11 @@ async def prefix(self, ctx: commands.Context, *, prefix: str):
await self.bot.reply_to_msg(ctx.message, f"Prefix changed to {prefix}.")

@BaseCmds.set.command(name="owo")
@commands.check(common.mod_only)
async def owo(self, ctx: commands.Context):
"""Usage: `set owo`
Purpose: toggle owo
Notes: owo what's this? you need to be engineer or above to use this"""
Notes: owo what's this? you need to be a mod to use this :3"""
self.bot.owo = not self.bot.owo
await ctx.reply("OwO" if self.bot.owo else "no owo :(")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fred"
version = "2.22.7"
version = "2.22.8"
description = "A Discord bot for the Satisfactory Modding Discord "
authors = ["Feyko <[email protected]>", "Mircea Roata <[email protected]>", "Borketh <[email protected]>"]
license = "MIT License"
Expand Down
Loading