Compare commits

...

36 commits

Author SHA1 Message Date
98f491860d
remove gitlab ci
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful
2024-10-10 21:19:16 +02:00
a39ea9e50b
woodpecker 2024-10-10 21:15:04 +02:00
5c0feca7b2 Merge pull request 'Update dependency py-cord to v2.6.1' (#27) from renovate/py-cord-2.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #27
2024-09-28 22:01:59 +02:00
836d6b1d3d
Update dependency py-cord to v2.6.1
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2024-09-15 20:22:12 +00:00
4c261a30d4
fix issue with survey script
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-12 14:37:49 +02:00
a344db3ad1
add survey bot
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-12 14:20:28 +02:00
559d8c2169
make hiebe and liebe visible in help 2024-07-12 13:07:08 +02:00
91a75741bf
remove old help and old yesno 2024-07-12 13:02:21 +02:00
f16042d81a
Update to pycord 2.6.0 and fix the embed 2024-07-12 12:59:26 +02:00
be7db764ec
roll back to 2.4.1 because of breaking changes
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-11 21:37:12 +02:00
016d2f3730 Merge pull request 'Update dependency py-cord to v2.6.0' (#26) from renovate/py-cord-2.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #26
2024-07-11 10:20:39 +02:00
a526ec91f5
Update dependency py-cord to v2.6.0
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is passing
2024-07-09 19:10:23 +00:00
b0a3e48890
change compose directory
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-26 00:17:25 +02:00
b65bd7a363 Merge pull request 'Update dependency py-cord to v2.5.0' (#25) from renovate/py-cord-2.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #25
2024-03-16 03:27:11 +01:00
5948da8056
Update dependency py-cord to v2.5.0
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2024-03-02 09:19:30 +00:00
43a01a753b
fix container registry
All checks were successful
continuous-integration/drone/push Build is passing
2023-12-24 20:29:10 +01:00
2a46a54637
change container registry
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2023-12-24 20:27:54 +01:00
74fe90b242
update pipeline because of new docker compose
All checks were successful
continuous-integration/drone/push Build is passing
2023-11-25 21:21:35 +01:00
f9c496d158
update pipeline
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-24 04:35:05 +02:00
e753423957
remove whitespace
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-29 23:04:57 +02:00
ee561c5356
reduce prune days to 7 2023-05-29 23:04:45 +02:00
4a029f3bcd
Update python Docker tag to v3.11.3
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone Build is passing
continuous-integration/drone/push Build is passing
2023-04-06 01:07:49 +00:00
f6e2e961f1 Merge pull request 'Update dependency py-cord to v2.4.1' (#23) from renovate/py-cord-2.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #23
2023-03-21 00:07:07 +01:00
b5ec9bac92 Update dependency py-cord to v2.4.1
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-03-20 23:06:42 +00:00
a0aa24bb41
update README for gitea environment
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-13 22:19:42 +01:00
b2f1c795e6 Merge pull request 'Update dependency py-cord to v2.4.0' (#22) from renovate/py-cord-2.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #22
2023-02-11 15:15:45 +01:00
5fdf2b666c Update dependency py-cord to v2.4.0
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-11 13:16:49 +00:00
37c9f0376a Merge pull request 'Update dependency py-cord to v2.3.3' (#21) from renovate/py-cord-2.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #21
2023-02-11 13:22:44 +01:00
b4fbdc7628 Update dependency py-cord to v2.3.3
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-11 03:15:50 +00:00
749190bc61 Merge pull request 'Update python Docker tag to v3.11.2' (#20) from renovate/python-3.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #20
2023-02-09 10:44:20 +01:00
a34af09beb Update python Docker tag to v3.11.2
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-02-09 02:26:51 +00:00
81f84dddf4 Update dependency py-cord to v2.3.2
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2022-12-13 23:58:02 +00:00
7fa890eb28 Merge pull request 'Update dependency py-cord to v2.3.0' (#17) from renovate/py-cord-2.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #17
2022-12-13 23:42:38 +01:00
36b6077d02 Merge pull request 'Update python Docker tag to v3.11.1' (#18) from renovate/python-3.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #18
2022-12-13 23:42:23 +01:00
b4116bf6a0 Update python Docker tag to v3.11.1
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-12-08 05:05:20 +00:00
65a7e9048e Update dependency py-cord to v2.3.0
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-11-23 22:05:20 +00:00
9 changed files with 138 additions and 210 deletions

View file

@ -1,81 +0,0 @@
kind: pipeline
name: deploy
steps:
- name: docker
image: plugins/docker
settings:
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_PASSWORD
repo: secondhemd/shbot
tags: latest
when:
branch:
- master
event:
- push
- name: docker-build
image: plugins/docker
settings:
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_PASSWORD
repo: secondhemd/shbot
tags: latest
dry_run: true
when:
exclude:
branch:
- master
event:
- push
- name: dev docker
image: plugins/docker
settings:
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_PASSWORD
repo: secondhemd/shbot
tags: dev
when:
branch:
- dev
event:
- push
- name: deploy
image: appleboy/drone-ssh
settings:
host:
- s.ar21.de
username: root
key:
from_secret: DEPLOY_SSH_KEY
port: 22
command_timeout: 2m
script:
- cd /root && docker-compose pull shbot && docker-compose up -d shbot
when:
branch:
- master
event:
- push
- name: deploy dev
image: appleboy/drone-ssh
settings:
host:
- s.ar21.de
username: root
key:
from_secret: DEPLOY_SSH_KEY
port: 22
command_timeout: 2m
script:
- cd /root && docker-compose -f shbot-dev.yaml pull shbot-dev && docker-compose -f shbot-dev.yaml up -d shbot-dev
when:
branch:
- dev
event:
- push

View file

@ -1,91 +0,0 @@
stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy
docker-build-push:
# Use the official docker image.
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
allow_failure: false
only:
- master
docker-build-push-dev:
# Use the official docker image.
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:dev" .
- docker push "$CI_REGISTRY_IMAGE:dev"
allow_failure: false
only:
- dev
- merge_requests
docker-build:
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
allow_failure: false
except:
- master
- dev
- merge_requests
include:
- template: Security/Container-Scanning.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml
container_scanning:
variables:
DOCKER_IMAGE: "$CI_REGISTRY_IMAGE${tag}"
stage: test
allow_failure: false
deploy_dev:
stage: deploy
image: debian
before_script:
- apt-get update -qq
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh $SSH_SERVER "cd /root && docker-compose -f shbot-dev.yaml pull shbot-dev && docker-compose -f shbot-dev.yaml up -d shbot-dev && exit"
only:
- dev
- merge_requests
deploy_staging:
stage: deploy
image: debian
before_script:
- apt-get update -qq
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh $SSH_SERVER "cd /root && docker-compose pull shbot && docker-compose up -d shbot && exit"
only:
- master

42
.woodpecker/.build.yaml Normal file
View file

@ -0,0 +1,42 @@
steps:
- name: docker
image: woodpeckerci/plugin-docker-buildx
settings:
registry: git.ar21.de
username:
from_secret: REGISTRY_USER
password:
from_secret: REGISTRY_PASS
repo: git.ar21.de/secondhemd/shbot
tags: latest
when:
- branch: master
event: [push, manual]
- name: docker-build
image: woodpeckerci/plugin-docker-buildx
settings:
registry: git.ar21.de
username:
from_secret: REGISTRY_USER
password:
from_secret: REGISTRY_PASS
repo: git.ar21.de/secondhemd/shbot
tags: latest
dry_run: true
when:
- branch:
exclude: [master, dev]
event: [push, manual]
- name: dev docker
image: woodpeckerci/plugin-docker-buildx
settings:
registry: git.ar21.de
username:
from_secret: REGISTRY_USER
password:
from_secret: REGISTRY_PASS
repo: git.ar21.de/secondhemd/shbot
tags: dev
when:
- branch: dev
event: [push, manual]

34
.woodpecker/.deploy.yaml Normal file
View file

@ -0,0 +1,34 @@
skip_clone: true
steps:
- name: deploy
image: appleboy/drone-ssh
settings:
host:
- s.ar21.de
username: root
key:
from_secret: DEPLOY_SSH_KEY
port: 22
command_timeout: 2m
script:
- cd ~/compose/shbot && docker compose pull shbot && docker compose up -d shbot
when:
- branch: master
event: [push, manual]
- name: deploy dev
image: appleboy/drone-ssh
settings:
host:
- s.ar21.de
username: root
key:
from_secret: DEPLOY_SSH_KEY
port: 22
command_timeout: 2m
script:
- cd /root && docker compose -f shbot-dev.yaml pull shbot-dev && docker compose -f shbot-dev.yaml up -d shbot-dev
when:
- branch: dev
event: [push, manual]
depends_on:
- build

View file

@ -1,4 +1,4 @@
FROM amd64/python:3.10.8-alpine3.16 FROM amd64/python:3.11.3-alpine3.16
WORKDIR ./ WORKDIR ./
ARG PUID=1000 ARG PUID=1000

View file

@ -1,22 +1,22 @@
# SECOND BOT # SECOND BOT
[![pipeline status](https://git.cxservers.com/aaron-riedel/shbot/badges/master/pipeline.svg)](https://git.cxservers.com/aaron-riedel/shbot/-/commits/master) [![Build Status](https://drone.ar21.de/api/badges/secondhemd/shbot/status.svg)](https://drone.ar21.de/secondhemd/shbot)
der Bot für den SecondHemd Discord der Bot für den SecondHemd Discord
# Latest # Latest
## Build ## Build
``` ```
docker build -t docker-registry.cxservers.com/aaron-riedel/shbot:latest . docker build -t secondhemd/shbot:latest .
``` ```
## Run ## Run
``` ```
sudo docker run -e 'TOKEN=' -e 'PREFIX=$' -t docker-registry.cxservers.com/aaron-riedel/shbot:latest sudo docker run -e 'TOKEN=' -e 'PREFIX=$' -t secondhemd/shbot:latest
``` ```
## Docker compose ## Docker compose
``` ```
services: services:
bot: bot:
image: docker-registry.cxservers.com/aaron-riedel/shbot:latest image: secondhemd/shbot:latest
container_name: shbot container_name: shbot
restart: unless-stopped restart: unless-stopped
environment: environment:
@ -27,17 +27,17 @@ services:
# Development # Development
## Build ## Build
``` ```
docker build -t docker-registry.cxservers.com/aaron-riedel/shbot:dev . docker build -t secondhemd/shbot:dev .
``` ```
## Run ## Run
``` ```
sudo docker run -e 'TOKEN=' -e 'PREFIX=$' -t docker-registry.cxservers.com/aaron-riedel/shbot:dev sudo docker run -e 'TOKEN=' -e 'PREFIX=$' -t secondhemd/shbot:dev
``` ```
## Docker compose ## Docker compose
``` ```
services: services:
bot: bot:
image: docker-registry.cxservers.com/aaron-riedel/shbot:dev image: secondhemd/shbot:dev
container_name: shbot container_name: shbot
restart: unless-stopped restart: unless-stopped
environment: environment:

34
bot.py
View file

@ -188,24 +188,6 @@ async def emoji_text(ctx, message: discord.Message):
modal.set_message_id(message.id) modal.set_message_id(message.id)
await ctx.interaction.response.send_modal(modal) await ctx.interaction.response.send_modal(modal)
@bot.command(help="veraltet", usage="", hidden=True)
@is_member()
async def yesno(ctx):
await ctx.message.delete()
await ctx.send(content="Sorry das geht so nicht. Der Befehl hat sich geändert in !vote... für mehr Informationen schreib bitte !help oder frage deinen Admin oder Apotheker. Liebste Grüße, SecondBot <3", delete_after=20.0)
@bot.command(help="Zeigt alte Hilfe", usage="")
@is_member()
async def helpme(ctx):
if admin(ctx):
admin_text = "\n\n!add = Hinzufügen einer Rolle mit Textchannel und hinzufügen von Usern zur Rolle\nNutzung: !add \"<Rolle>\" <User Mentions>\n\n!labor = bringt dich ins Labor :)\nNutzung: !labor\n\n!start = Starte ne Runde PnP\nNutzung: !start @Rolle\n\n!stop = Beende die gestartete Runde PnP\nNutzung: !stop\n\n!purge = Löschen von Nachrichten\nNutzung: !purge all|<Anzahl>|x minutes/hours/days/weeks\n\n!prune - kickt Member ohne Rolle, die 30 Tage nicht online waren\nNutzung: !prune"
else:
admin_text = ""
em = discord.Embed(title="Hilfe",description="!survey = Umfrage mit mehreren Antwortmöglichkeiten\nNutzung: !survey <Frage> | <Antwort1> | <Antwort2> ...\n\n!vote = Ja/Nein Umfrage\nNutzung: !vote <Frage>\n\n!love = zeige einem User Liebe\nNutzung: !love <@User1> <@User2> ...\n\n!roll = Rolle einen oder mehrere Würfel\nNutzung: !roll <anzahl_optional>W<seitenzahl> (z.B. !roll W20 oder !roll 10W6)%s" % admin_text, colour=0x00FF00)
if ctx.author.dm_channel == None:
await ctx.author.create_dm()
await ctx.author.dm_channel.send(embed=em)
@bot.command(help="Umfrage mit mehreren Antwortmöglichkeiten", usage="<Frage> | <Antwort1> | <Antwort2> ...") @bot.command(help="Umfrage mit mehreren Antwortmöglichkeiten", usage="<Frage> | <Antwort1> | <Antwort2> ...")
@is_member() @is_member()
async def survey(ctx, *, arg): async def survey(ctx, *, arg):
@ -219,7 +201,7 @@ async def survey(ctx, *, arg):
desc = desc + emojinumbers[z] + " - " + y + "\n" desc = desc + emojinumbers[z] + " - " + y + "\n"
z = z + 1 z = z + 1
em = discord.Embed(title=question, description=desc, colour=0x00E0FF) em = discord.Embed(title=question, description=desc, colour=0x00E0FF)
em.set_author(name=ctx.author.display_name, url=discord.Embed.Empty, icon_url=ctx.author.avatar.url) em.set_author(name=ctx.author.display_name, url=None, icon_url=ctx.author.avatar.url)
ask_msg = await ctx.send(content="||@everyone||",embed=em) ask_msg = await ctx.send(content="||@everyone||",embed=em)
a = 0 a = 0
for x in emojinumbers: for x in emojinumbers:
@ -244,7 +226,7 @@ async def surveyedit(ctx, *, arg):
desc = desc + emojinumbers[z] + " - " + y + "\n" desc = desc + emojinumbers[z] + " - " + y + "\n"
z = z + 1 z = z + 1
em = discord.Embed(title=question, description=desc, colour=0x00E0FF) em = discord.Embed(title=question, description=desc, colour=0x00E0FF)
em.set_author(name=ctx.author.display_name, url=discord.Embed.Empty, icon_url=ctx.author.avatar.url) em.set_author(name=ctx.author.display_name, url=None, icon_url=ctx.author.avatar.url)
survey_msg = await ctx.channel.fetch_message((int(survey_id))) survey_msg = await ctx.channel.fetch_message((int(survey_id)))
await survey_msg.edit(embed=em) await survey_msg.edit(embed=em)
@ -253,7 +235,7 @@ async def surveyedit(ctx, *, arg):
async def vote(ctx, *, arg): async def vote(ctx, *, arg):
await ctx.message.delete() await ctx.message.delete()
em = discord.Embed(description=arg, colour=0x00E0FF) em = discord.Embed(description=arg, colour=0x00E0FF)
em.set_author(name=ctx.author.display_name, url=discord.Embed.Empty, icon_url=ctx.author.avatar.url) em.set_author(name=ctx.author.display_name, url=None, icon_url=ctx.author.avatar.url)
ask_msg = await ctx.send(content="||@everyone||",embed=em) ask_msg = await ctx.send(content="||@everyone||",embed=em)
for x in ["", "", ""]: for x in ["", "", ""]:
await ask_msg.add_reaction(x) await ask_msg.add_reaction(x)
@ -396,7 +378,7 @@ async def purge(ctx, *, arg):
deleted = await ctx.channel.purge(limit=limit) deleted = await ctx.channel.purge(limit=limit)
await ctx.send(content='Ich habe {} Nachrichten gelöscht.'.format(len(deleted)), delete_after=5.0) await ctx.send(content='Ich habe {} Nachrichten gelöscht.'.format(len(deleted)), delete_after=5.0)
@bot.command(help="zeige einem User Liebe", usage="<@User1> <@User2> ...", hidden=True) @bot.command(help="zeige einem User Liebe", usage="<@User1> <@User2> ...")
@is_member() @is_member()
async def liebe(ctx, *, arg): async def liebe(ctx, *, arg):
await ctx.message.delete() await ctx.message.delete()
@ -405,7 +387,7 @@ async def liebe(ctx, *, arg):
await user.create_dm() await user.create_dm()
await user.dm_channel.send("❤️ von {}".format(ctx.author.display_name)) await user.dm_channel.send("❤️ von {}".format(ctx.author.display_name))
@bot.command(help="zeige einem User Hiebe", usage="<@User1> <@User2> ...", hidden=True) @bot.command(help="zeige einem User Hiebe", usage="<@User1> <@User2> ...")
@is_member() @is_member()
async def hiebe(ctx, *, arg): async def hiebe(ctx, *, arg):
await ctx.message.delete() await ctx.message.delete()
@ -414,7 +396,7 @@ async def hiebe(ctx, *, arg):
await user.create_dm() await user.create_dm()
await user.dm_channel.send("HIEBE :punch: von {}".format(ctx.author.display_name)) await user.dm_channel.send("HIEBE :punch: von {}".format(ctx.author.display_name))
@bot.command(help="kickt Member ohne Rolle, die 30 Tage nicht online waren", usage="") @bot.command(help="kickt Member ohne Rolle, die 7 Tage nicht online waren", usage="")
@is_admin() @is_admin()
async def prune(ctx): async def prune(ctx):
await ctx.message.delete() await ctx.message.delete()
@ -427,8 +409,8 @@ async def prune(ctx):
await ctx.send(content="Zeit ausgelaufen", delete_after=5.0) await ctx.send(content="Zeit ausgelaufen", delete_after=5.0)
elif view.value: elif view.value:
await question.delete() await question.delete()
deleted = await ctx.guild.prune_members(days=30) deleted = await ctx.guild.prune_members(days=7)
await ctx.send(content='Ich habe {} Leichen beseitigt.'.format(deleted), delete_after=5.0) await ctx.send(content='Ich habe {} Leiche(n) beseitigt.'.format(deleted), delete_after=5.0)
else: else:
await question.delete() await question.delete()

View file

@ -1 +1 @@
py-cord==2.2.2 py-cord==2.6.1

42
survey.py Normal file
View file

@ -0,0 +1,42 @@
import discord
import asyncio
import time
import datetime
import random
import os
from os import system
from os import environ
from discord.ext import commands
from discord.commands import Option
from discord.commands import permissions
from discord.ui import InputText, Modal
def left(s, amount):
return s[:amount]
def right(s, amount):
return s[-amount:]
def mid(s, offset, amount):
return s[offset:offset+amount]
token = os.environ['TOKEN']
survey_channel = int(os.environ['SURVEY_CHANNEL'])
mention_id = int(os.environ['MENTION_ID'])
guild_id = int(os.environ['GUILD_ID'])
runtime = 48
bot = discord.Bot(description=None)
@bot.event
async def on_ready():
print("Bot ready on Version %s..." % discord.__version__)
# build survey
po = discord.Poll(question="Wie habt ihr nächste Woche Zeit?", answers=[discord.PollAnswer(text="Montag", emoji="1\u20E3"), discord.PollAnswer(text="Dienstag", emoji="2\u20E3"), discord.PollAnswer(text="Mittwoch", emoji="3\u20E3"), discord.PollAnswer(text="Donnerstag", emoji="4\u20E3"), discord.PollAnswer(text="Freitag", emoji="5\u20E3"), discord.PollAnswer(text="Samstag", emoji="6\u20E3"), discord.PollAnswer(text="Sonntag", emoji="7\u20E3"), discord.PollAnswer(text="keine Zeit", emoji="")], duration=runtime, allow_multiselect=True)
# send message
msg = await bot.get_channel(survey_channel).send(content="||%s||"% bot.get_guild(guild_id).get_role(mention_id).mention ,poll=po)
await msg.create_thread(name="Diskussion")
# close connection
await bot.close()
bot.run(token)