Files
ninachloe/FaustBot/Modules/LetterObserver.py
ThomasWeis 95c1f93e5b Create LetterObserver.py
Module chooses a random letter from the German alphabet (includig ä, ö, ü; not including ß)
2022-04-20 15:32:33 +02:00

26 lines
862 B
Python

from FaustBot.Communication import Connection
from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype
import random
class LetterObserver(PrivMsgObserverPrototype):
@staticmethod
def cmd():
return [".abc"]
@staticmethod
def help():
return ".abc - wählt einen zufälligen Buchstaben aus"
def update_on_priv_msg(self, data: dict, connection: Connection):
if data['message'].find('.abc') == -1:
return
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', 'ä', 'ö', 'ü']
#choose a random letter from alphabet list
letter = random.choice(alphabet).upper()
connection.send_back('Gewählter Buchstabe: ' + letter, data)