Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
390bf8a489 | ||
|
|
74aa78c748 | ||
|
|
379f280c11 | ||
|
|
7d1e69c007 | ||
|
|
b905ce7216 | ||
|
|
4bb7db3f71 | ||
|
|
b3f48d4603 | ||
|
|
90763c73a7 | ||
|
|
635419dc7c | ||
|
|
2356d5edbf | ||
|
|
9eed0a1f4e | ||
|
|
a9a6ab4520 | ||
|
|
e08a764591 | ||
|
|
8b43f766b3 | ||
|
|
cb9cad9783 | ||
|
|
216becff6e | ||
|
|
836673198a | ||
|
|
e34739a0b1 | ||
|
|
7c592e6acc | ||
|
|
0f8637be23 | ||
|
|
3b597aeac7 | ||
|
|
c43b2297a4 | ||
|
|
1b337a291d | ||
|
|
16b662875f | ||
|
|
640d481018 |
@@ -0,0 +1,20 @@
|
||||
name: build_develop
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install Docker
|
||||
uses: https://github.com/papodaca/install-docker-action@v1
|
||||
- name: Build Docker Image
|
||||
run: docker build -t viker.cheezers.net:5000/agon:develop .
|
||||
- name: Push Docker Image
|
||||
run: docker push viker.cheezers.net:5000/agon:develop
|
||||
@@ -0,0 +1,24 @@
|
||||
name: build_release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v[0-9].[0-9].[0-9]"]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install Docker
|
||||
uses: https://github.com/papodaca/install-docker-action@v1
|
||||
- name: Set env
|
||||
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
- name: Build Docker Images
|
||||
run: docker build -t viker.cheezers.net:5000/agon:latest -t viker.cheezers.net:5000/agon:${{env.GIT_TAG}} .
|
||||
- name: Push Latest Image
|
||||
run: docker push viker.cheezers.net:5000/agon:latest
|
||||
- name: Push Tagged Image
|
||||
run: docker push viker.cheezers.net:5000/agon:${{env.GIT_TAG}}
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# this file is intended to build the docker image and push to the correct repository. Intended to be run by my buildbot instance.
|
||||
|
||||
# build, tag, and push develop
|
||||
docker build -t viker.cheezers.net:5000/agon:develop .
|
||||
docker push viker.cheezers.net:5000/agon:develop
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# this file is intended to build the docker image and push to the correct repository. Intended to be run by my buildbot instance.
|
||||
|
||||
# check if there is a git tag. if so, tag with that tag and release
|
||||
# expecting tag to be 6 characters long. otherwise isn't not the right tag
|
||||
GITTAG=$(git describe --tags)
|
||||
length=${#GITTAG}
|
||||
|
||||
if [ $length -eq 6 ]; then
|
||||
docker build -t viker.cheezers.net:5000/agon:release -t viker.cheezers.net:5000/agon:$GITTAG .
|
||||
docker push viker.cheezers.net:5000/agon:release
|
||||
docker push viker.cheezers.net:5000/agon:$GITTAG
|
||||
else
|
||||
docker build -t viker.cheezers.net:5000/agon:release .
|
||||
docker push viker.cheezers.net:5000/agon:release
|
||||
fi
|
||||
@@ -8,7 +8,6 @@ from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from utilities.sql_data_classes import Guild, engine
|
||||
from utilities.utils import add_preset_configuration
|
||||
|
||||
|
||||
class GuildListener(commands.Cog, name="Guild Listener"):
|
||||
@@ -21,7 +20,7 @@ class GuildListener(commands.Cog, name="Guild Listener"):
|
||||
async def on_guild_join(self, guild: nextcord.Guild):
|
||||
"""Listener for Guild Join. Adds guild to database."""
|
||||
|
||||
new_guild = Guild(GuildId=guild.id)
|
||||
new_guild = Guild(GuildId=guild.id, GuildName=guild.name)
|
||||
|
||||
with Session(engine) as session:
|
||||
session.add(new_guild)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
Initializing code for all loops.
|
||||
"""
|
||||
|
||||
from nextcord.ext import commands
|
||||
|
||||
from .bot_presence import BotPresence
|
||||
from .guild_data import GuildData
|
||||
|
||||
|
||||
# This function will be called when this extension is loaded.
|
||||
# It is necessary to add these functions to the bot.
|
||||
def setup(bot: commands.Bot):
|
||||
"""Adds function to bot"""
|
||||
bot.add_cog(BotPresence(bot))
|
||||
bot.add_cog(GuildData(bot))
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Functions for controlling the bot's presence.
|
||||
Functions for controlling the bot's presence. Also contains the loop.
|
||||
"""
|
||||
|
||||
import random
|
||||
@@ -46,10 +46,3 @@ class BotPresence(commands.Cog, name="Bot Presence"):
|
||||
status += f" | {len(self.bot.guilds)} servers"
|
||||
|
||||
await self.bot.change_presence(activity=nextcord.Game(status))
|
||||
|
||||
|
||||
# This function will be called when this extension is loaded.
|
||||
# It is necessary to add these functions to the bot.
|
||||
def setup(bot: commands.Bot):
|
||||
"""Adds function to bot"""
|
||||
bot.add_cog(BotPresence(bot))
|
||||
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
Contains a loop that updates guild data in the database periodically.
|
||||
"""
|
||||
|
||||
from nextcord.ext import commands, tasks
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from utilities.sql_data_classes import Guild, engine
|
||||
|
||||
|
||||
class GuildData(commands.Cog, name="Guild Data"):
|
||||
"""Class to contain loop."""
|
||||
|
||||
def __init__(self, bot: commands.bot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_ready(self):
|
||||
"""Starts the loop when bot is ready."""
|
||||
await self.bot.wait_until_ready()
|
||||
# pylint doesn't recognize that periodic_update_guild_data is subclassed from tasks.loop.
|
||||
await self.periodic_update_guild_data.start() # pylint: disable=no-member
|
||||
|
||||
@tasks.loop(hours=24)
|
||||
async def periodic_update_guild_data(self):
|
||||
"""Loops every day, calls update_guild_data."""
|
||||
self.update_guild_data()
|
||||
|
||||
def update_guild_data(self):
|
||||
"""
|
||||
Updates all known guild's data in the database.
|
||||
"""
|
||||
with Session(engine) as session:
|
||||
for guild in self.bot.guilds:
|
||||
# update given guild name for guild id
|
||||
stmt = select(Guild).where(Guild.GuildId == guild.id)
|
||||
guild_data = session.scalar(stmt)
|
||||
|
||||
# just in case checking if the guild doesn't exist.
|
||||
if guild_data is None:
|
||||
new_guild = Guild(GuildId=guild.id, GuildName=guild.name)
|
||||
session.add(new_guild)
|
||||
else:
|
||||
guild_data.GuildName = guild.name
|
||||
|
||||
session.commit()
|
||||
@@ -3,6 +3,7 @@ use highscores;
|
||||
|
||||
CREATE TABLE Guilds(
|
||||
GuildId bigint unsigned not null unique,
|
||||
GuildName varchar(95) not null,
|
||||
SubmissionChannel bigint unsigned,
|
||||
VerificationChannel bigint unsigned,
|
||||
PRIMARY KEY (GuildId)
|
||||
|
||||
Reference in New Issue
Block a user