mirror of
https://github.com/nichkara/InfinitumBotty.git
synced 2026-06-11 06:36:24 +02:00
DDOS/Spam protection
This commit is contained in:
@@ -5,6 +5,10 @@ from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype
|
|||||||
|
|
||||||
|
|
||||||
class BastelObserver(PrivMsgObserverPrototype):
|
class BastelObserver(PrivMsgObserverPrototype):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.annoyed: int = 0
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def cmd():
|
def cmd():
|
||||||
"""
|
"""
|
||||||
@@ -36,12 +40,32 @@ class BastelObserver(PrivMsgObserverPrototype):
|
|||||||
"""
|
"""
|
||||||
if data['message'].find('.craft') == -1:
|
if data['message'].find('.craft') == -1:
|
||||||
return
|
return
|
||||||
connection.send_back("\001ACTION rennt in die Werkstatt!\001", data)
|
|
||||||
sleep(5)
|
|
||||||
connection.send_back("\001ACTION poltert herum!", data)
|
|
||||||
|
|
||||||
# Determine, what Botty has built (random wikipedia article)
|
# Start not more than one process with a longer iteration (15 seconds)
|
||||||
crafted_object = wikipedia.random(1)
|
if self.annoyed > 0:
|
||||||
sleep(5)
|
if self.annoyed == 1:
|
||||||
connection.send_back(
|
connection.send_back("Lass mich in Ruhe arbeiten!", data)
|
||||||
f"\001ACTION kommt zurück und hat {crafted_object} gebastelt.\001", data)
|
elif self.annoyed == 2:
|
||||||
|
connection.send_back("Ich muss mich konzentrieren!", data)
|
||||||
|
elif self.annoyed == 3:
|
||||||
|
connection.send_back("So kann ich nicht arbeiten!", data)
|
||||||
|
else:
|
||||||
|
connection.send_back("\001ACTION wirft mit Werkzeug um sich!\001", data)
|
||||||
|
|
||||||
|
# Bot is getting more annoyed when hit on multiple times
|
||||||
|
# self.annoyed is again checked against zero, as it's more likely to prevent a deadlock
|
||||||
|
if self.annoyed > 0:
|
||||||
|
self.annoyed = self.annoyed + 1
|
||||||
|
else:
|
||||||
|
self.annoyed = 1
|
||||||
|
connection.send_back("\001ACTION rennt in die Werkstatt.\001", data)
|
||||||
|
sleep(10)
|
||||||
|
connection.send_back("\001ACTION poltert herum.", data)
|
||||||
|
|
||||||
|
# Determine, what Botty has built (random wikipedia article)
|
||||||
|
wikipedia.set_lang('de')
|
||||||
|
crafted_object = wikipedia.random(1)
|
||||||
|
sleep(5)
|
||||||
|
connection.send_back(
|
||||||
|
f"\001ACTION kommt zurück und hat {crafted_object} gebastelt.\001", data)
|
||||||
|
self.annoyed = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user