Skip to content
Snippets Groups Projects
Unverified Commit 53b5dfcf authored by dnns01's avatar dnns01 Committed by GitHub
Browse files

Deploy emoji-hunt (#138)


* Advent calendar (#131)

* Advent calendar (#132)

* Merge learninggroup changes to release (#128)

* First attempt for auto qa via Github Action

* Try changing directory

* Check Git Status

* Check pwd for debugging

* Copy checked out repo to deploy directory

* Let Boty get restarted =)

* Avoid TypeErrors with missing .env entries (#114)

* Disnake migration (#113)

* Add pip update

* Remove Timer from Bot (temporarily) (#117)

* Test Webhook

* Next Webhook test

* Added private learninggroups and confirm dialog

* send message to user when request is not accepted (#118)

* send message to user when request is not accepted

* add message to user with direct link to the group when request is accepted.

* add dialog with custom buttons (#119)

* Lerngruppenfunktionalität gefixt (#123)

* Fix learninggroups button handling

* talki talki talk talk talk - more messages to inform users about status updates

* added mod-role to permissions and fix help (#124)

* fix forgotten awaits on channel.send() calls (#125)

* fix lg owner can't be a member but dnns made it (#126)

* added open, close, private state to learninggroups (#127)

* added open, close, private state to learninggroups

* fix logical issue in show and hide

* add discriminator to lg memberlists

* add seperator to help cards

* fix open channel got permissions / add discriminator to statusmessage

* fix message not send on state change success

* fix typo prevents message to be shown

* fix range from 4 to 6 causes error when lou does her 666 things

* add debug command to show on the fly channel confings

* change "Benutzer" and "Besitzer" to female forms

Co-authored-by: default avatarFabian <75286597+ffaadd@users.noreply.github.com>

* Add advent calendar functionality using threads and preparation channels

* Add message when day is assigne in newly created channel

Co-authored-by: default avatarFabian <75286597+ffaadd@users.noreply.github.com>

* Advent calendar (#133)

* Merge learninggroup changes to release (#128)

* First attempt for auto qa via Github Action

* Try changing directory

* Check Git Status

* Check pwd for debugging

* Copy checked out repo to deploy directory

* Let Boty get restarted =)

* Avoid TypeErrors with missing .env entries (#114)

* Disnake migration (#113)

* Add pip update

* Remove Timer from Bot (temporarily) (#117)

* Test Webhook

* Next Webhook test

* Added private learninggroups and confirm dialog

* send message to user when request is not accepted (#118)

* send message to user when request is not accepted

* add message to user with direct link to the group when request is accepted.

* add dialog with custom buttons (#119)

* Lerngruppenfunktionalität gefixt (#123)

* Fix learninggroups button handling

* talki talki talk talk talk - more messages to inform users about status updates

* added mod-role to permissions and fix help (#124)

* fix forgotten awaits on channel.send() calls (#125)

* fix lg owner can't be a member but dnns made it (#126)

* added open, close, private state to learninggroups (#127)

* added open, close, private state to learninggroups

* fix logical issue in show and hide

* add discriminator to lg memberlists

* add seperator to help cards

* fix open channel got permissions / add discriminator to statusmessage

* fix message not send on state change success

* fix typo prevents message to be shown

* fix range from 4 to 6 causes error when lou does her 666 things

* add debug command to show on the fly channel confings

* change "Benutzer" and "Besitzer" to female forms

Co-authored-by: default avatarFabian <75286597+ffaadd@users.noreply.github.com>

* Add advent calendar functionality using threads and preparation channels

* Add message when day is assigne in newly created channel

* Add commands to show the whole assignments and to reassign a day

* Fix permissions in reassign command

Co-authored-by: default avatarFabian <75286597+ffaadd@users.noreply.github.com>

* winter is coming

added bot's wintery profile picture

* Easter -> Emoji_hunt für mehr Anlässen (#135)

* Update and rename easter.py to emoji_hunt.py

* Update fernuni_bot.py

* Rebranding

* Letzte sprachliche Anpassungen

* Uncomment emoji hunt

* Fix indentation

* Further indentation fixes

* Remove empty help decorator

* Add tasks import

* Add random import

Co-authored-by: default avatarFabian <75286597+ffaadd@users.noreply.github.com>
Co-authored-by: default avatarLou-M <73669620+Lou-M@users.noreply.github.com>
parent 538561bf
No related branches found
No related tags found
No related merge requests found
import json
import random
import disnake
from disnake.ext import commands
from disnake.ext import commands, tasks
from cogs.help import handle_error
class Easter(commands.Cog):
class EmojiHunt(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.data = self.load_data()
# self.messages = []
# self.reaction_timer.start()
self.messages = []
self.reaction_timer.start()
def load_data(self):
data_file = open("data/easter.json", mode="r")
data_file = open("data/emoji_hunt.json", mode="r")
return json.load(data_file)
def save_data(self):
data_file = open("data/easter.json", mode="w")
data_file = open("data/emoji_hunt.json", mode="w")
json.dump(self.data, data_file)
# @commands.Cog.listener(name="on_message")
# async def hide(self, message):
# if message.author == self.bot.user:
# return
#
# if message.channel.id in self.data["channels"]:
# if random.random() < self.data["probability"]:
# self.messages.append(message)
#
# @commands.Cog.listener(name="on_raw_reaction_add")
# async def seek(self, payload):
#
# if payload.member == self.bot.user or payload.message_id not in self.data["message_ids"]:
# return
#
# modifier = 1 if payload.emoji.name in self.data["reactions_add"] else -1 if payload.emoji.name in self.data[
# "reactions_remove"] else 0
# if modifier != 0:
# self.data["message_ids"].remove(payload.message_id)
# self.modify_leaderboard(payload.user_id, modifier)
#
# channel = await self.bot.fetch_channel(payload.channel_id)
# message = await channel.fetch_message(payload.message_id)
# await message.clear_reaction(payload.emoji.name)
# self.save_data()
#
# def modify_leaderboard(self, user_id, modifier):
# if score := self.data["leaderboard"].get(str(user_id)):
# self.data["leaderboard"][str(user_id)] = score + modifier
# else:
# self.data["leaderboard"][str(user_id)] = modifier
#
# self.save_data()
#@help()
@commands.Cog.listener(name="on_message")
async def hide(self, message):
if message.author == self.bot.user:
return
if message.channel.id in self.data["channels"]:
if random.random() < self.data["probability"]:
self.messages.append(message)
@commands.Cog.listener(name="on_raw_reaction_add")
async def seek(self, payload):
if payload.member == self.bot.user or payload.message_id not in self.data["message_ids"]:
return
modifier = 1 if payload.emoji.name in self.data["reactions_add"] else -1 if payload.emoji.name in self.data[
"reactions_remove"] else 0
if modifier != 0:
self.data["message_ids"].remove(payload.message_id)
self.modify_leaderboard(payload.user_id, modifier)
channel = await self.bot.fetch_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
await message.clear_reaction(payload.emoji.name)
self.save_data()
def modify_leaderboard(self, user_id, modifier):
if score := self.data["leaderboard"].get(str(user_id)):
self.data["leaderboard"][str(user_id)] = score + modifier
else:
self.data["leaderboard"][str(user_id)] = modifier
self.save_data()
@commands.command(name="leaderboard")
async def cmd_leaderboard(self, ctx, all=None):
leaderboard = self.data["leaderboard"]
embed = disnake.Embed(title="Egg-Hunt Leaderboard", description="Wer hat bisher die meisten Eier gefunden???")
embed.set_thumbnail(url="https://www.planet-wissen.de/kultur/religion/ostern/tempxostereiergjpg100~_v-gseagaleriexl.jpg")
embed = disnake.Embed(title="Emojijagd Leaderboard", description="Wer hat am meisten Emojis gefunden?")
embed.set_thumbnail(url="https://external-preview.redd.it/vFsRraBXc5hfUGRWtPPF-NG5maHEPRWTIqamB24whF8.jpg?width=960&crop=smart&auto=webp&s=24d42c9b4f5239a4c3cac79e704b7129c9e2e4d3")
places = scores = "\u200b"
place = 0
......@@ -80,28 +81,27 @@ class Easter(commands.Cog):
except:
pass
embed.add_field(name=f"Sucherin", value=places)
embed.add_field(name=f"Eier", value=scores)
embed.add_field(name=f"Jägerin", value=places)
embed.add_field(name=f"Emojis", value=scores)
await ctx.send("", embed=embed)
# @tasks.loop(seconds=1)
# async def reaction_timer(self):
# delete = []
#
# for message in self.messages:
# if random.random() < 0.6:
# if random.random() < 0.85:
# await message.add_reaction(random.choice(self.data["reactions_add"]))
# else:
# await message.add_reaction(random.choice(self.data["reactions_remove"]))
#
# self.data["message_ids"].append(message.id)
# delete.append(message)
# self.save_data()
#
# if len(delete) > 0:
# for message in delete:
# self.messages.remove(message)
@tasks.loop(seconds=1)
async def reaction_timer(self):
delete = []
for message in self.messages:
if random.random() < 0.6:
if random.random() < 0.85:
await message.add_reaction(random.choice(self.data["reactions_add"]))
else:
await message.add_reaction(random.choice(self.data["reactions_remove"]))
self.data["message_ids"].append(message.id)
delete.append(message)
self.save_data()
if len(delete) > 0:
for message in delete:
self.messages.remove(message)
async def cog_command_error(self, ctx, error):
await handle_error(ctx, error)
......@@ -4,7 +4,7 @@ import disnake
from disnake.ext import commands
from dotenv import load_dotenv
from cogs import appointments, calmdown, christmas, easter, github, help, learninggroups, links, \
from cogs import appointments, calmdown, christmas, emoji_hunt, github, help, learninggroups, links, \
news, polls, roles, support, text_commands, voice, welcome, xkcd, module_information
from view_manager import ViewManager
......@@ -35,7 +35,7 @@ class Boty(commands.Bot):
self.add_cog(news.News(self))
self.add_cog(links.Links(self))
self.add_cog(voice.Voice(self))
self.add_cog(easter.Easter(self))
self.add_cog(emoji_hunt.EmojiHunt(self))
self.add_cog(learninggroups.LearningGroups(self))
self.add_cog(module_information.ModuleInformation(self))
self.add_cog(xkcd.Xkcd(self))
......
images/Botys_Profilbild_winter.png

149 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment