예제 #1
0
def query_raid_vip() -> query.Query:
    return session.query(User.twitch_user_name,
                         User.id). \
        join(Raid). \
        filter(and_(User.stream_badges == 'Tueftlie', User.warnings == 0)). \
        group_by(Raid.raider_user_id). \
        order_by(func.count(Raid.raider_user_id).desc(),
                 func.sum(Raid.number_of_raiders).desc()). \
        limit(tetueSrc.get_int_element("autovip", "num_max_auto_vips_raid"))
예제 #2
0
def query_auto_vip() -> query.Query:
    unsorted_user_list = [[
        user, (user.number_of_logins * 0.5) + (user.loyalty_points * 1) +
        (user.honor_counter * 2)
    ] for user in session.query(User).filter(
        and_(User.stream_badges == 'Tueftlie', User.warnings == 0))]
    sorted_user_list = sorted(unsorted_user_list,
                              key=lambda x: x[1],
                              reverse=True)
    return sorted_user_list[:tetueSrc.get_int_element(
        "autovip", "num_max_auto_vips_loyalty")]
예제 #3
0
def check_spam_cmd(bot, user):
    # Prüft ob der User den cmd Befehl als Spam benutzt. Wenn Anzahl überschritten, bekommt er ein
    # Timeout aber keine Verwarnung eingetragen.
    if not tetueSrc.get_int_element("automod", "num_failed_cmd_thr_active") or \
            not temp_failed_cmd_thr_active: return True
    user.failedCmd += 1
    print("Falscher CMD")
    if user.failedCmd >= failed_cmd_thr:
        bot.send_message(f"/timeout {user.get_displayname()} 1m")
        bot.send_message(f"{user.get_displayname()}, du hast einen Timeout bekommen, weil du zu häufig falsche Befehle "
                         f"eingegeben hast. Die Timeoutlänge beträgt 1 Minute.")
        user.failedCmd = 0
        return False
    else:
        return True
예제 #4
0
def statistics(bot, user, *args):
    pecking_order_length, pecking_order_place = place_on_pecking_order(user)
    auto_vip_order_length, auto_vip_order_place = place_on_auto_vip_order(user)
    award = user.user_award
    hen_name = user.db_data.hen_name
    if hen_name is not None:
        if award is not None:
            hen_award_message = f"Du besitzt den Hühnernamen: {hen_name} und deine Auszeichnung ist: {award}. "
        else:
            hen_award_message = f"Du besitzt den Hühnernamen: {hen_name}. "
    else:
        if award is not None:
            hen_award_message = f"Deine Auszeichnung ist: {award}. "
        else:
            hen_award_message = ""

    if pecking_order_place is not None:
        pecking_message = f"In der Hackordnung bist du auf dem {pecking_order_place+1}ten Platz. "
    else:
        pecking_message = ""

    if auto_vip_order_place is not None:
        num_max_auto_vips_loyalty = tetueSrc.get_int_element(
            "autovip", "num_max_auto_vips_loyalty")
        auto_vip_message = f"Dein Rang im Auto-VIP Highscore ist {auto_vip_order_place+1}/{auto_vip_order_length}. " \
                           f"Die ersten {num_max_auto_vips_loyalty} bekommen am Anfang eines Streams den VIP-Status. "
    else:
        auto_vip_message = ""

    welcome_message = f"@{user.db_data.twitch_user_name}, mit dir sind noch {pecking_order_length} weitere Hühner " \
                      f"im Stall. "

    game_statistics_text = game_statistics(bot, user, *args)
    if game_statistics_text is not None:
        game_statistics_message = game_statistics_text
    else:
        game_statistics_message = "Bisher hast du an keinem Chatspiel teilgenommen. Probier einfach mal !"

    composed_message = (welcome_message + hen_award_message + pecking_message +
                        auto_vip_message + game_statistics_message)

    if len(composed_message) < 500:
        bot.send_message(composed_message)
    else:
        bot.send_message(composed_message[:500])
        print(
            f"Nachricht bei <Stats> länger als 500 Zeichen von User: {user.db_data.twitch_user_name}"
        )
예제 #5
0
import db
import tetueSrc
import re
from datetime import datetime

warning_timers = (1, 5, 60)
filler_sign_list = tetueSrc.get_string_list("automod", "list_filler_sign")
bad_word_list = tetueSrc.get_string_list("automod", "list_badwords")
failed_cmd_thr = tetueSrc.get_int_element("automod", "num_failed_cmd_thr")
bad_advertising_word_thr = tetueSrc.get_string_list("automod", "bad_advertising_word_thr")
pattern_1 = r"\bbuy\b | \bfollowers\b | \bprimes\b | \bviewers\b | \bon\b"
temp_failed_cmd_thr_active = True


def trigger_lurk_bots(bot):
    trigger_time_for_lurk_bots = tetueSrc.get_string_list("automod", "time_last_bot_started")
    time_thr = tetueSrc.get_string_list("automod", "time_thr_lurk_bot_start_in_days")
    if (datetime.now() - datetime.strptime(trigger_time_for_lurk_bots, "%d/%m/%y %H:%M:%S")).days < time_thr: return
    tetueSrc.save_timestamp_element("automod", "time_last_bot_started", datetime.now())
    trigger_categories_for_lurk_bots = tetueSrc.get_string_list("automod", "trigger_categories")
    channel_info = bot.get_channel_info()
    correct_category = any([True for category in trigger_categories_for_lurk_bots if category == channel_info["Game"]])
    if correct_category is False: return
    trigger_words_for_lurk_bots = tetueSrc.get_string_list("automod", "trigger_lurk_bots")
    if len(trigger_words_for_lurk_bots) == 0: return
    output_text = "Probleme über Probleme und ein planloser TeTü. Ich wünschte "
    if len(trigger_words_for_lurk_bots) < 2:
        output_text += "@" + trigger_words_for_lurk_bots[0] + " wäre hier!"
    else:
        for i in range(len(trigger_words_for_lurk_bots) - 1):
            output_text += "@" + trigger_words_for_lurk_bots[i]
예제 #6
0
from datetime import datetime
from sys import exit

import db
import react
import tetueSrc
import user_management

read_successful, cfg = tetueSrc.get_configuration("bot")
OWNER = cfg["owner"]
TWEETMAXLENGTH = tetueSrc.get_int_element("general", "hashtag_max_length")
TWEETWELCOME = tetueSrc.get_string_element("general", "tweet_welcome")
TWEETMINSIZE = tetueSrc.get_int_element("general", "hashtag_min_size")
hashtag_tweet_list = {"#twitchstreamer", "#TwitchDE", "#knorzen"}


def get_trigger_commands_output_text() -> list:
    loaded_config = tetueSrc.get_string_list_only_section("output_text")
    return [
        element for key, value in loaded_config.items()
        for element in value['commands'] if value['active']
    ]


trigger_commands_output_text = get_trigger_commands_output_text()


def load_new_command_infos(bot, user, *args):
    global trigger_commands_output_text
    tetueSrc.load_configuration()
    loaded_config = tetueSrc.get_string_list_only_section("output_text")
예제 #7
0
import games
import tetueSrc
import user_management
import automod

messages = defaultdict(int)

# "Emote from a another world"
emotes_another_world = ["(y)"]
# K/D Counter
cfg_kd = tetueSrc.get_string_element("paths", "kd")
# Hen name
HENNAME = tetueSrc.get_string_element("hunname", "id")
avail_hen_name_list = list()
# Auto-Vip
LOYALITYPOINT_1 = tetueSrc.get_int_element("autovip", "num_loy_point_1")
LOYALITYPOINT_2 = tetueSrc.get_int_element("autovip", "num_loy_point_2")
LOYALITYPOINT_3 = tetueSrc.get_int_element("autovip", "num_loy_point_3")
# Channel points
CP_LIEGESTUETZE = tetueSrc.get_string_element("general", "cp_liege_stue")
CP_TRINKWAS = tetueSrc.get_string_element("general", "cp_wasser_marsch")
CP_CENTER_SHOCK = tetueSrc.get_string_element("general", "cp_center_shock")


def process(bot, user, message):
    update_records(bot, user)
    update_loyalty_points(user)
    update_kd_counter(bot)
    games.run_time_processes(bot, user, message)
    if user.id == "100135110":  # StreamElements
        update_bot_helper(bot, user, message)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import tetueSrc
import tweepy
# tetueSrc.log_event_warning("")
read_successful, cfg_owner = tetueSrc.get_configuration("twitter")

client = tweepy.Client(bearer_token=cfg_owner["bearer_token"],
                       consumer_key=cfg_owner["consumer_key"],
                       consumer_secret=cfg_owner["consumer_secret"],
                       access_token=cfg_owner["access_token"],
                       access_token_secret=cfg_owner["access_token_secret"])

registered_hashtags = set(
    tetueSrc.get_string_list("twitter_bot", "start_hashtags"))
max_hashtags = tetueSrc.get_int_element("twitter_bot", "max_hashtags")
hashtag_min_size = tetueSrc.get_int_element("twitter_bot", "hashtag_min_size")
tweet_max_length = tetueSrc.get_int_element("twitter_bot", "tweet_max_length")


def register_hashtag(bot, user, hashtag, *args):
    global registered_hashtags
    if len(registered_hashtags) >= max_hashtags: return
    registered_hashtags.add(hashtag)


def main() -> None:
    pass


if __name__ == "__main__":
예제 #9
0
import time
from enum import Enum, auto
from random import choice, shuffle

import db
import tetueSrc
import user_management

TEAANSWERTIME = tetueSrc.get_int_element("tea_butler", "answer_time")
TEAANSWER = tetueSrc.get_string_list("tea_butler", "answer_butler")
TEA_EMOTE = tetueSrc.get_string_element("tea_butler", "emote_tea")
TEA_CMD = tetueSrc.get_string_list("tea_butler", "cmd_tea")
COFFEE_EMOTE = tetueSrc.get_string_element("tea_butler", "emote_coffee")
COFFEE_CMD = tetueSrc.get_string_list("tea_butler", "cmd_coffee")
QUOTESPATH = tetueSrc.get_string_element("tea_butler", "quotes_path")
HONORANSWERTIME = tetueSrc.get_int_element("feat_honor", "answer_time")
HONOR_MIN_DIVISOR = tetueSrc.get_string_list("feat_honor", "divisor")
DELETEANSWERTIME = tetueSrc.get_int_element("general", "answer_time")
RUSROULETTE_GAME_TIME = tetueSrc.get_int_element("roulette", "answer_time")
RUSROULETTE_GAME_TIMEOUT_TIME = tetueSrc.get_int_element(
    "roulette", "timeout_time")
RUSROULETTE_GAME_BET_AMOUNT = tetueSrc.get_int_element("roulette",
                                                       "bet_amount")

num_pronunciation = {
    1: "erste",
    2: "zweite",
    3: "dritte",
    4: "vierte",
    5: "fünfte",
    6: "sechste"