Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 08c58f10c2 | |||
| a380b9da82 | |||
| c8be6bffcc | |||
| dd4a037479 | |||
| a24fd875d8 | |||
| fb022f5a53 | |||
| 1d67cb2d92 | |||
| c3eff5ed7f | |||
| 22a3b14edd | |||
| 55ef585bdb | |||
| a9cf3af487 | |||
| 01e3138f29 | |||
| 46fc7d0d60 | |||
| a41a483041 | |||
| 917e90b48b | |||
| 467aebc3af | |||
| 818f4dfdae | |||
| 0db5d4d31c | |||
| 6967fa5358 | |||
| 70363033c1 | |||
| baf774f4b0 | |||
| 64215ffda5 | |||
| 13a9075376 | |||
| 05e72bf0dc | |||
| 654274f632 | |||
| 56d7a8155c | |||
| b82d6fa518 | |||
| c4cb477637 | |||
| 2f33d840f3 | |||
| f01b942818 | |||
| 8e1b4269d1 | |||
| e1455de14b | |||
| e6195d9a88 | |||
| 1221035369 | |||
| 796f43d629 | |||
| 0b031d20f9 | |||
| bfd497898e | |||
| 077f845b94 | |||
| 26e3a4bb8e | |||
| f56636c1ff | |||
| f427d06e61 | |||
| 42bd226a60 | |||
| 4dd578c9a8 | |||
| 01d90e6625 |
@@ -0,0 +1,13 @@
|
||||
###############################
|
||||
# Git Large File System (LFS) #
|
||||
###############################
|
||||
|
||||
# Images
|
||||
*.gif filter=lfs diff=lfs merge=lfs -text
|
||||
*.ico filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.webp filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
# Gradle wrapper
|
||||
gradle/wrapper/gradle-wrapper.jar filter=lfs diff=lfs merge=lfs -text
|
||||
+61
-152
@@ -1,173 +1,82 @@
|
||||
# Custom additions
|
||||
logs/*
|
||||
config/*.ini
|
||||
pastebin.txt
|
||||
.DS_Store
|
||||
test*.py
|
||||
.dockerignore
|
||||
docker-*
|
||||
.vscode
|
||||
########
|
||||
# Java #
|
||||
########
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
# Log file
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
##########
|
||||
# Gradle #
|
||||
##########
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
# Gradle files
|
||||
.gradle
|
||||
**/build/
|
||||
!**/src/**/build/
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
# Avoid ignore Gradle wrappper properties
|
||||
!gradle-wrapper.properties
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
# Gradle properties
|
||||
gradle.properties
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
||||
.pdm.toml
|
||||
.pdm-python
|
||||
.pdm-build/
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
#########
|
||||
# MacOS #
|
||||
#########
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
# General
|
||||
.DS_Store
|
||||
__MACOSX/
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon[]
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
########
|
||||
# Jenv #
|
||||
########
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
.java-version
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* This generated file contains a sample Java application project to get you started.
|
||||
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/9.2.0/userguide/building_java_projects.html in the Gradle documentation.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
// Apply the application plugin to add support for building a CLI application in Java.
|
||||
id 'application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Use Maven Central for resolving dependencies.
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Use JUnit Jupiter for testing.
|
||||
testImplementation libs.junit.jupiter
|
||||
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
|
||||
// This dependency is used by the application.
|
||||
implementation libs.guava
|
||||
}
|
||||
|
||||
// Apply a specific Java toolchain to ease working on different environments.
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
|
||||
application {
|
||||
// Define the main class for the application.
|
||||
mainClass = 'postit.App'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
// Use JUnit Platform for unit tests.
|
||||
useJUnitPlatform()
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
[DISCORD]
|
||||
TOKEN = <PLACE YOUR DISCORD TOKEN FROM THE DEV PORTAL HERE>
|
||||
OWNER_ID = <PLACE THE USER ID OF THE OWNER HERE>
|
||||
@@ -1,6 +0,0 @@
|
||||
; Create an script on the reddit developer page (https://www.reddit.com/prefs/apps)
|
||||
[REDDIT]
|
||||
CLIENT_ID = <PASTE YOUR CLIENT ID HERE>
|
||||
CLIENT_SECRET = <PASTE YOUR CLIENT SECRET HERE>
|
||||
USER_AGENT = Small discord bot to embed posts (given by url) into an standardized format
|
||||
EMBED_COLOR = 0xff4500
|
||||
@@ -0,0 +1,10 @@
|
||||
# This file was generated by the Gradle 'init' task.
|
||||
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
|
||||
|
||||
[versions]
|
||||
guava = "33.4.6-jre"
|
||||
junit-jupiter = "5.12.1"
|
||||
|
||||
[libraries]
|
||||
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
||||
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
|
||||
BIN
Binary file not shown.
+7
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,248 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+93
@@ -0,0 +1,93 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,3 +0,0 @@
|
||||
discord.py==2.4.0
|
||||
colorama==0.4.6
|
||||
python-dotenv==1.1.1
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* The settings file is used to specify which projects to include in your build.
|
||||
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/9.2.0/userguide/multi_project_builds.html in the Gradle documentation.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
// Apply the foojay-resolver plugin to allow automatic download of JDKs
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
|
||||
}
|
||||
|
||||
rootProject.name = 'PostIt'
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
from discord.ext import commands
|
||||
import discord
|
||||
from utils.datetime_tools import get_elapsed_time_small
|
||||
from logging import Logger
|
||||
from datetime import datetime
|
||||
|
||||
class PostIt_Bot(commands.Bot):
|
||||
"""Class to extend the built-in bot class"""
|
||||
def __init__(self, startup_time:float, program_version:str, app_logger:Logger):
|
||||
intents = discord.Intents.default()
|
||||
intents.messages = True
|
||||
super().__init__(command_prefix=None, help_command=None, intents=intents)
|
||||
|
||||
self.startup_time = startup_time
|
||||
self.PROGRAM_VERSION = program_version
|
||||
self.__logger = app_logger
|
||||
|
||||
async def setup_hook(self):
|
||||
# Register cogs to handle commands
|
||||
for cog_name in ["post", "reload"]:
|
||||
await self.load_extension(f"cogs.{cog_name}")
|
||||
await self.tree.sync()
|
||||
|
||||
async def on_ready(self):
|
||||
self.__logger.info(f"Successfully logged in (after {get_elapsed_time_small(datetime.now().timestamp() - self.startup_time)}) as {self.user}")
|
||||
@@ -1,15 +0,0 @@
|
||||
"""Contains the BaseCog"""
|
||||
|
||||
from discord.ext import commands
|
||||
import logging
|
||||
|
||||
class BaseCog(commands.Cog):
|
||||
def __init__(self, bot:commands.Bot, logger:logging.Logger):
|
||||
self._bot = bot
|
||||
self._logger = logger
|
||||
|
||||
async def cog_load(self):
|
||||
self._logger.debug(f"Cog for the '{self.__class__.__name__}' command got loaded")
|
||||
|
||||
async def cog_unload(self):
|
||||
self._logger.debug(f"Cog for the '{self.__class__.__name__}' command got unloaded")
|
||||
@@ -1,28 +0,0 @@
|
||||
"""Contains the implementation for the /post command"""
|
||||
|
||||
from .base import BaseCog
|
||||
import logging
|
||||
from discord import app_commands, Interaction
|
||||
from discord.ext import commands
|
||||
|
||||
class PostCommand(BaseCog):
|
||||
def __init__(self, bot):
|
||||
logger = logging.getLogger("cmds.post")
|
||||
super().__init__(bot, logger)
|
||||
|
||||
@app_commands.command(name = "post", description = "Post an embed in the Current Channel with a link to the content")
|
||||
@app_commands.describe(url = "URL to the post", custom_note = "Describe the post with your own note", use_title = "Display the title of the post", quality = "Specifies the quality of the converted image, closer to 100 is better")
|
||||
@app_commands.choices(quality = [
|
||||
app_commands.Choice(name = "Poor (60)", value = 60),
|
||||
app_commands.Choice(name = "Fair (70)", value = 70),
|
||||
app_commands.Choice(name = "Good (80)", value = 80),
|
||||
app_commands.Choice(name = "Very Good (85)", value = 85),
|
||||
app_commands.Choice(name = "Excellent (90)", value = 90),
|
||||
app_commands.Choice(name = "Superior (95)", value = 95),
|
||||
app_commands.Choice(name = "Perfect (100)", value = 100)
|
||||
])
|
||||
async def post(self, ctx:Interaction, url:str, custom_note:str = None, use_title:bool = True, quality:app_commands.Choice[int] = 95):
|
||||
print("Hallo")
|
||||
|
||||
async def setup(bot:commands.Bot):
|
||||
await bot.add_cog(PostCommand(bot))
|
||||
@@ -1,113 +0,0 @@
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from .base import BaseCog
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from utils.datetime_tools import get_elapsed_time_milliseconds
|
||||
|
||||
class ReloadCommand(BaseCog):
|
||||
def __init__(self, bot:commands.Bot):
|
||||
self.__bot = bot
|
||||
self.__cached_cog_names:list[str] = None
|
||||
self.__reload_running = False
|
||||
super().__init__(bot, logging.getLogger("cmds.reload"))
|
||||
|
||||
async def autocomplete_cog(self, ctx: discord.Interaction, cog_name_stw:str):
|
||||
"""Helpermethod to recommend the right cog name to the user"""
|
||||
# Cache the cog names if not cached yet
|
||||
if not self.__cached_cog_names:
|
||||
self.__cached_cog_names = list(self.__bot.extensions.keys())
|
||||
|
||||
if cog_name_stw == "":
|
||||
# Return first 25 cog names, if provided name is empty
|
||||
matching_cogs = sorted(self.__cached_cog_names)
|
||||
else:
|
||||
matching_cogs = []
|
||||
for cog_name in self.__cached_cog_names:
|
||||
if cog_name.startswith(cog_name_stw.lower()):
|
||||
matching_cogs.append(cog_name)
|
||||
|
||||
choices = []
|
||||
for matching_cog in matching_cogs[:25]:
|
||||
choices.append(app_commands.Choice(name = matching_cog.removeprefix("cogs.").capitalize(), value = matching_cog))
|
||||
|
||||
return choices
|
||||
|
||||
@app_commands.command(name = "reload_all", description = "Reloads all cogs")
|
||||
async def reload_all(self, ctx: discord.Interaction):
|
||||
if self.__reload_running:
|
||||
await ctx.response.send_message("Reload is allready being executed", ephemeral = True)
|
||||
else:
|
||||
self.__reload_running = True
|
||||
task_start = datetime.now().timestamp()
|
||||
cog_names = list(self.__bot.extensions.keys())
|
||||
stepped_over = 0
|
||||
self._logger.debug(f"Reloading all {len(cog_names)} cogs / extensions ...")
|
||||
try:
|
||||
embed_cog_stats = "Reloaded the following cogs:\n"
|
||||
for extension_name in cog_names:
|
||||
if "impls" in extension_name:
|
||||
stepped_over += 1
|
||||
else:
|
||||
start_reload = datetime.now().timestamp()
|
||||
await self.__bot.reload_extension(extension_name)
|
||||
embed_cog_stats += f"- {extension_name.removeprefix('cogs.').capitalize()} (`{get_elapsed_time_milliseconds(datetime.now().timestamp() - start_reload)}`)\n"
|
||||
|
||||
except Exception as error:
|
||||
embed_cog_stats += f"- {extension_name.removeprefix('cogs.').capitalize()} <--"
|
||||
|
||||
embed = discord.Embed(
|
||||
title = "Reloading All Cogs",
|
||||
description = f"{embed_cog_stats} \n\nDuring the reload an exception occured",
|
||||
color = 0xED4337)
|
||||
|
||||
raise error
|
||||
else:
|
||||
elapsed_time = get_elapsed_time_milliseconds(datetime.now().timestamp() - task_start)
|
||||
embed = discord.Embed(
|
||||
title = "Reloading All Cogs",
|
||||
description = f"{embed_cog_stats}Total time spend: `{elapsed_time}`",
|
||||
color = 0x4BB543)
|
||||
|
||||
self._logger.info(f"Cogs successfully reloaded after {elapsed_time} (Ignored )")
|
||||
finally:
|
||||
await ctx.response.send_message(embed = embed, ephemeral = True)
|
||||
self.__reload_running = False
|
||||
|
||||
|
||||
@app_commands.command(name = "reload", description = "Reload specific cog")
|
||||
@app_commands.autocomplete(cog_name = autocomplete_cog)
|
||||
async def reload(self, ctx: discord.Interaction, cog_name:str):
|
||||
if self.__reload_running:
|
||||
await ctx.response.send_message("Reload is allready being executed", ephemeral = True)
|
||||
else:
|
||||
self.__reload_running = True
|
||||
task_start = datetime.now().timestamp()
|
||||
self._logger.debug(f"Reloading {cog_name} cog ...")
|
||||
try:
|
||||
await self.__bot.reload_extension(cog_name)
|
||||
except Exception as error:
|
||||
embed = discord.Embed(
|
||||
title = f"Reloading `{cog_name.removeprefix('cogs.').capitalize()}` cog",
|
||||
description = "Reload failed with an exception",
|
||||
color = 0xED4337)
|
||||
|
||||
raise error
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
title = f"Reloading `{cog_name.removeprefix('cogs.').capitalize()}` cog",
|
||||
description = f"Total time spend: `{get_elapsed_time_milliseconds(datetime.now().timestamp() - task_start)}`",
|
||||
color = 0x4BB543)
|
||||
|
||||
self._logger.info(f"Cog {cog_name} successfully reloaded after {get_elapsed_time_milliseconds(datetime.now().timestamp() - task_start)}")
|
||||
finally:
|
||||
await ctx.response.send_message(embed = embed, ephemeral = True)
|
||||
self.__reload_running = False
|
||||
|
||||
# Clear the cache
|
||||
self.__cached_cog_names = None
|
||||
|
||||
async def setup(bot:commands.Bot):
|
||||
await bot.add_cog(ReloadCommand(bot))
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
from utils.logger.custom_logging import Custom_Logger
|
||||
import logging
|
||||
from pathlib import Path
|
||||
import sys, signal
|
||||
import os
|
||||
import dotenv
|
||||
from bot import PostIt_Bot
|
||||
from utils.datetime_tools import get_elapsed_time_milliseconds, get_elapsed_time_big
|
||||
import discord
|
||||
|
||||
async def main():
|
||||
PROGRAM_VERSION = "1.0"
|
||||
print(" ____ ____ ___________ __________")
|
||||
print(" / __ \/ __ \/ ___/_ __/ / _/_ __/")
|
||||
print(" / /_/ / / / /\__ \ / /_____ / / / / ")
|
||||
print(" / ____/ /_/ /___/ // /_____// / / / ")
|
||||
print(f" /_/ \____//____//_/ /___/ /_/ v{PROGRAM_VERSION}")
|
||||
print(" Copyright (c) 2024-2025 Lars Winzer")
|
||||
print()
|
||||
print(" Source: https://github.com/official-Cromatin/Post-It")
|
||||
print(" Report an Issue: https://github.com/official-Cromatin/Post-It/issues/new?assignees=&labels=bug&projects=&template=issue_report.yml")
|
||||
print("\n")
|
||||
|
||||
# Get timestamp for begin of actual execution
|
||||
startup_time = datetime.now().timestamp()
|
||||
|
||||
# Initialize the logger
|
||||
Custom_Logger.initialize()
|
||||
app_logger = logging.getLogger("app")
|
||||
app_startup_logger = logging.getLogger("app.startup")
|
||||
app_startup_logger.info(f"Starting Post-It v{PROGRAM_VERSION} ...")
|
||||
|
||||
# Detect entrypoint
|
||||
source_path = Path(__file__).resolve()
|
||||
base_path = source_path.parents[1]
|
||||
app_startup_logger.info(f"Using the following path as entrypoint: '{base_path}'")
|
||||
|
||||
# Detect operating system and attach
|
||||
shutdown_event = asyncio.Event()
|
||||
def signal_handler(*args):
|
||||
app_logger.info("Shutdown signal recieved, shutting down")
|
||||
shutdown_event.set()
|
||||
|
||||
match sys.platform:
|
||||
case "linux":
|
||||
app_startup_logger.info("Detected platform: Linux")
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
case "darwin":
|
||||
app_startup_logger.info("Detected platform: MacOS (Darwin)")
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
case "win32":
|
||||
app_startup_logger.info("Detected platform: Windows (Win32)")
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
case _:
|
||||
app_startup_logger.fatal(f"Detected unsupported platform: {sys.platform}")
|
||||
quit(1)
|
||||
|
||||
# Load environment variables
|
||||
if (os.getenv("skip_dotenv", False)):
|
||||
app_startup_logger.warning("Skipped import of dotenv file")
|
||||
else:
|
||||
dotenv.load_dotenv(base_path / ".env")
|
||||
app_startup_logger.warning("Imported dotenv file")
|
||||
|
||||
# Check if required environment variables are present
|
||||
check_ok = True
|
||||
required_variables = [
|
||||
"DISCORD_TOKEN",
|
||||
]
|
||||
|
||||
for variable_name in required_variables:
|
||||
if os.getenv(variable_name) is None:
|
||||
app_startup_logger.error(f"Environment variable '{variable_name}' is missing")
|
||||
check_ok = False
|
||||
|
||||
if not check_ok:
|
||||
app_startup_logger.critical("Multiple required variables are missing. Aborting startup")
|
||||
quit(1)
|
||||
|
||||
# Create bot instance and start bot
|
||||
app_startup_logger.info(f"Preperations complete after {get_elapsed_time_milliseconds(datetime.now().timestamp() - startup_time)}, launching bot")
|
||||
try:
|
||||
bot_instance = PostIt_Bot(startup_time, PROGRAM_VERSION, app_logger)
|
||||
|
||||
bot_task = asyncio.create_task(bot_instance.start(os.getenv("DISCORD_TOKEN")))
|
||||
shutdown_task = asyncio.create_task(shutdown_event.wait())
|
||||
|
||||
# Wait if either the bot disconnects or the shutdown event is detected
|
||||
finished_task, _ = await asyncio.wait(
|
||||
[shutdown_task, bot_task],
|
||||
return_when = asyncio.FIRST_COMPLETED
|
||||
)
|
||||
|
||||
if shutdown_task in finished_task:
|
||||
await bot_instance.close()
|
||||
app_logger.info("Bot closed connection successfully")
|
||||
|
||||
except discord.errors.LoginFailure:
|
||||
app_logger.critical("Improper token has been passed. Aborting startup")
|
||||
quit(1)
|
||||
|
||||
finally:
|
||||
app_logger.info(f"Exiting. Application ran for {get_elapsed_time_big(datetime.now().timestamp() - startup_time)}")
|
||||
|
||||
# Entry point for execution
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* This source file was generated by the Gradle 'init' task
|
||||
*/
|
||||
package postit;
|
||||
|
||||
public class App {
|
||||
public String getGreeting() {
|
||||
return "Hello World!";
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(new App().getGreeting());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* This source file was generated by the Gradle 'init' task
|
||||
*/
|
||||
package postit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class AppTest {
|
||||
@Test void appHasAGreeting() {
|
||||
App classUnderTest = new App();
|
||||
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
from datetime import datetime
|
||||
|
||||
def get_elapsed_time(timestamp:float) -> str:
|
||||
"""Convert an timestamp into an predefined elapsed time format (00min 00sec), without miliseconds"""
|
||||
time_elapsed = datetime.fromtimestamp(timestamp)
|
||||
return f"{time_elapsed.minute // 60}min {time_elapsed.second:02}sec"
|
||||
|
||||
def get_elapsed_time_ms(timestamp:float) -> str:
|
||||
"""Convert an timestamp into an predefined elapsed time format (00min 00sec 000ms), with miliseconds"""
|
||||
time_elapsed = datetime.fromtimestamp(timestamp)
|
||||
return f"{time_elapsed.minute // 60}min {time_elapsed.second:02}sec {time_elapsed.microsecond // 1000}ms"
|
||||
|
||||
def get_elapsed_time_small(timestamp:float) -> str:
|
||||
"""Convert an timestamp into an predefined elapsed time format (00sec 000ms)"""
|
||||
time_elapsed = datetime.fromtimestamp(timestamp)
|
||||
return f"{time_elapsed.second:02}sec {time_elapsed.microsecond // 1000:03}ms"
|
||||
|
||||
def get_elapsed_time_big(timestamp:float) -> str:
|
||||
"""Convert an timestamp into an predefined elapsed time format (00days 00hrs 00min)"""
|
||||
time_elapsed = datetime.fromtimestamp(timestamp)
|
||||
return f"{time_elapsed.day - 1}days {time_elapsed.hour - 1}hrs {1 if time_elapsed.minute == 0 else time_elapsed.minute}min"
|
||||
|
||||
def get_elapsed_time_milliseconds(timestamp:float) -> str:
|
||||
"""Convert an timestamp into an predefined elapsed time format (0000ms)"""
|
||||
time_elapsed = datetime.fromtimestamp(timestamp)
|
||||
return f"{time_elapsed.second * 1000 + time_elapsed.microsecond // 1000}ms"
|
||||
@@ -1,37 +0,0 @@
|
||||
import logging
|
||||
from utils.logger.formatter import Colored_Formatter
|
||||
|
||||
class Custom_Logger:
|
||||
console_handler: logging.StreamHandler
|
||||
colored_formatter: Colored_Formatter
|
||||
|
||||
@classmethod
|
||||
def initialize(cls):
|
||||
# Create the handler for logging to the console
|
||||
cls.console_handler = logging.StreamHandler()
|
||||
cls.console_handler.setLevel(logging.DEBUG)
|
||||
|
||||
# Create the colorful formatter
|
||||
cls.colored_formatter = Colored_Formatter()
|
||||
cls.console_handler.setFormatter(cls.colored_formatter)
|
||||
|
||||
# Create the loggers for the different sections of the app
|
||||
discordpy_logger = logging.getLogger("discord")
|
||||
discordpy_logger.addHandler(cls.console_handler)
|
||||
discordpy_logger.setLevel(logging.INFO)
|
||||
|
||||
app_logger = logging.getLogger("app")
|
||||
app_logger.addHandler(cls.console_handler)
|
||||
app_logger.setLevel(logging.DEBUG)
|
||||
|
||||
utils_logger = logging.getLogger("utils")
|
||||
utils_logger.addHandler(cls.console_handler)
|
||||
utils_logger.setLevel(logging.DEBUG)
|
||||
|
||||
commands_logger = logging.getLogger("cmds")
|
||||
commands_logger.addHandler(cls.console_handler)
|
||||
commands_logger.setLevel(logging.DEBUG)
|
||||
|
||||
logging.getLogger('discord.app_commands.tree').setLevel(logging.DEBUG)
|
||||
|
||||
app_logger.debug("Logging successfully initialized")
|
||||
@@ -1,11 +0,0 @@
|
||||
from functools import wraps
|
||||
import discord
|
||||
|
||||
def log_command_execution(func):
|
||||
"""Wraps an command function to print execution logs to the console"""
|
||||
@wraps(func)
|
||||
async def wrapper(self, interaction:discord.Interaction, *args, **kwargs):
|
||||
self._logger.debug(f"User {interaction.user} in channel {interaction.channel} on guild {interaction.guild} executed the {func.__name__} command")
|
||||
|
||||
return await func(self, interaction, *args, **kwargs)
|
||||
return wrapper
|
||||
@@ -1,30 +0,0 @@
|
||||
from logging import Formatter
|
||||
from colorama import Style, Fore
|
||||
|
||||
class Colored_Formatter(Formatter):
|
||||
def __init__(self, fmt=None, datefmt='%Y-%m-%d %H:%M:%S', style='%'):
|
||||
super().__init__(fmt, datefmt, style)
|
||||
|
||||
def format(self, record):
|
||||
# Formatieren des Zeitstempels fett
|
||||
date = f"{Style.BRIGHT}{Fore.BLACK}{self.formatTime(record, self.datefmt)}{Style.RESET_ALL}"
|
||||
|
||||
# Färben des Log-Levels mit fester Breite
|
||||
levelname_color = {
|
||||
'DEBUG': Fore.CYAN,
|
||||
'INFO': Fore.BLUE,
|
||||
'WARNING': Fore.YELLOW,
|
||||
'ERROR': Fore.RED,
|
||||
'CRITICAL': f"{Style.BRIGHT}{Fore.RED}"
|
||||
}
|
||||
levelname = f"{levelname_color.get(record.levelname, Fore.WHITE)}{record.levelname:<8}{Fore.RESET}{Style.RESET_ALL}"
|
||||
|
||||
# Färben des Logger-Namens in Magenta mit fester Breite
|
||||
name = f"{Fore.MAGENTA}{record.name:<20}{Fore.RESET}"
|
||||
|
||||
# Die Nachricht bleibt unverändert
|
||||
message = record.getMessage()
|
||||
|
||||
# Zusammenfügen der gefärbten Teile
|
||||
formatted_record = f"{date} {levelname} {name} {message}"
|
||||
return formatted_record
|
||||
Reference in New Issue
Block a user