This commit is contained in:
parent
3b4015e974
commit
49339ebcb9
@ -1,7 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from telegram.ext import ConversationHandler, CommandHandler, MessageHandler, filters, CallbackQueryHandler
|
from telegram.ext import MessageHandler, filters
|
||||||
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
|
|
||||||
from telegram import Update
|
from telegram import Update
|
||||||
import re
|
import re
|
||||||
import random
|
import random
|
||||||
@ -18,37 +17,47 @@ TURTLE_VIDEOS = list(TURTLE_VIDEO_LOCATION.glob("*.mp4"))
|
|||||||
class TurtleHandler(BaseHandler):
|
class TurtleHandler(BaseHandler):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.entry_string = "Variation of hallo"
|
self.entry_string = "Variation of hallo"
|
||||||
self.handler = MessageHandler(filters.Regex(r"[hH]([aA]+|[eE]+)[lL]{2,}[oOöÖ]+(le)?|(chen)") | # react to hello strings
|
self.handler = MessageHandler(
|
||||||
filters.Regex(b"\xF0\x9F\x90\xA2".decode("utf8")) | # react to turtle emoji
|
filters.Regex(r"[hH]([aA]+|[eE]+)[lL]{2,}[oOöÖ]+(le)?|(chen)") |
|
||||||
filters.Regex(r"[sS](childkröte)|[tT](urtle)"), # react to turtle string
|
# react to hello strings
|
||||||
self.entry_point)
|
filters.Regex(b"\xF0\x9F\x90\xA2".decode("utf8")) |
|
||||||
pass
|
# react to turtle emoji
|
||||||
|
filters.Regex(r"[sS](childkröte)|[tT](urtle)"),
|
||||||
|
# react to turtle string
|
||||||
|
self.entry_point
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def entry_point(self, update: Update, context):
|
async def entry_point(self, update: Update, context):
|
||||||
await super().entry_point(update, context)
|
await super().entry_point(update, context)
|
||||||
msgtxt = update.message.text
|
msgtxt = update.message.text
|
||||||
turtle_emoji = b"\xF0\x9F\x90\xA2".decode("utf8")
|
turtle_emoji = b"\xF0\x9F\x90\xA2".decode("utf8")
|
||||||
|
|
||||||
if "hallo" in msgtxt: # react to hallo
|
if "hallo" in msgtxt:
|
||||||
|
# react to hallo
|
||||||
vid = TURTLE_VIDEOS[0]
|
vid = TURTLE_VIDEOS[0]
|
||||||
answertxt = "Hallo!"
|
answertxt = "Hallo!"
|
||||||
elif re.search("[eE][lL]{2,}[oO]", msgtxt): # react to hello
|
elif re.search("[eE][lL]{2,}[oO]", msgtxt):
|
||||||
|
# react to hello
|
||||||
vid = TURTLE_VIDEOS[2]
|
vid = TURTLE_VIDEOS[2]
|
||||||
answertxt = "Hello!"
|
answertxt = "Hello!"
|
||||||
elif re.search("([aA]{4,}|[lL]{4,}|[oO]{4,}|[öÖ]{4,})", msgtxt): # react to stretched hello
|
elif re.search("([aA]{4,}|[lL]{4,}|[oO]{4,}|[öÖ]{4,})", msgtxt):
|
||||||
|
# react to stretched hello
|
||||||
vid = TURTLE_VIDEOS[5]
|
vid = TURTLE_VIDEOS[5]
|
||||||
answertxt = "That's a lot of letters!"
|
answertxt = "That's a lot of letters!"
|
||||||
elif re.search(turtle_emoji, msgtxt): # react to turtle emoji
|
elif re.search(turtle_emoji, msgtxt):
|
||||||
vid=TURTLE_VIDEOS[0] # TODO: choose video for smiley reaction
|
# react to turtle emoji
|
||||||
|
vid=TURTLE_VIDEOS[0]
|
||||||
answertxt="Turtle detected! Self-destruction mode activated..."
|
answertxt="Turtle detected! Self-destruction mode activated..."
|
||||||
elif re.search("[sS](childkröte)|[tT](urtle)", msgtxt): # react to turtle string
|
elif re.search("[sS](childkröte)|[tT](urtle)", msgtxt):
|
||||||
|
# react to turtle string
|
||||||
vid=None
|
vid=None
|
||||||
answertxt=turtle_emoji
|
answertxt=turtle_emoji
|
||||||
else:
|
else:
|
||||||
vid = random.choice(TURTLE_VIDEOS[1:2]+TURTLE_VIDEOS[3:5]+TURTLE_VIDEOS[6:])
|
vid = random.choice(TURTLE_VIDEOS[1:2]+TURTLE_VIDEOS[3:5]+TURTLE_VIDEOS[6:])
|
||||||
answertxt = ""
|
answertxt = ""
|
||||||
|
|
||||||
if vid!=None:
|
if vid != None:
|
||||||
if re.search(turtle_emoji, msgtxt):
|
if re.search(turtle_emoji, msgtxt):
|
||||||
await update.message.reply_text(text=answertxt)
|
await update.message.reply_text(text=answertxt)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user