예제 #1
0
def c_trp(client, message):
	result = translate(sh.get_args(message), "auto", "pl")
	
	if result[0] is None:
		yield from client.send_message(message.channel, sh.mention(message) + "brak wyników, albo Google się zesrało.")
	else:
		yield from client.send_message(message.channel, sh.mention(message) + "[" + result[1] + " => pl] " + result[0])
예제 #2
0
def c_tr(client, message):
	args = parse_args(sh.get_args(message))
	result = translate(args["msg"], args["in_lang"], args["out_lang"])
	
	if result[0] is None:
		yield from client.send_message(message.channel, sh.mention(message) + "brak wyników, albo Google się zesrało.")
	else:
		yield from client.send_message(message.channel, sh.mention(message) + "[" + result[1] + " => " + args["out_lang"] + "] " + result[0])
예제 #3
0
def c_google_image_face(client, message):
    result = google(sh.get_args(message), "itp:face")

    if not result:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + "brzydal")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result["url"])
예제 #4
0
def c_shitpostbot(client, message):
    result = tumblr_random("shitpostbot5k")

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + " I have a crippling depression")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result)
예제 #5
0
def c_youtube(client, message):
    result = yt(sh.get_args(message))

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak wyników, albo jutub się zesrał.")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result["url"])
예제 #6
0
def c_google_image_gif(client, message):
    result = google(sh.get_args(message), "itp:animated")

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak wyników, albo Google się zesrało.")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result["url"])
예제 #7
0
def c_dice(client, message):
    """.dice <formula> - Rolls dice using the XdY format, also does basic (+-*/) math."""
    #MATHTIME! Let's prepare the failsafes.
    legal_formula, no_dice = 1, 1
    #parsing time.
    msg = sh.get_args(message)
    formula = msg  #back-up the original message, because you're going to feed it back to the user in the end.
    formula = formula.replace("-", " - ")
    formula = formula.replace("+", " + ")  #add spaces
    formula = formula.replace("/", " / ")  #for all
    formula = formula.replace("*", " * ")  #the characters
    formula = formula.replace("(", " ( ")  #supported
    formula = formula.replace(")", " ) ")
    arr = formula.split(
        " ")  #aaaand, CUT IT APART! (this is why you needed the spaces.)
    full_string = ""  #reset the formula
    for segment in arr:
        #let's look at this formula... piece, by, piece
        if segment != "":
            #the value of this segment is 0
            value = 0
            if re.search("[0-9]*(d|D|k|K)[0-9]+",
                         segment):  #if there's a dice (regex FTW!)
                value = rollDice(segment.lower())  #then roll the dice.
                no_dice = 0  # And let the bot know there's dice in the formula
            elif re.search(
                    "([0-9]|\+|\-|\*|\/|\(|\)| \+| \-| \*| \/| \(| \))",
                    segment
            ):  #are any of the supported math characters in this piece?
                value = segment  #then just make that the value.
            else:
                legal_formula = 0  #non-supported character found...
                break  #ABORT, ABORT, ABORT!
            full_string += value  #add this segment's value to the full string
    #repeat next segment
    #you done? good.
    if legal_formula == 1 and full_string != "":  # did something break? no? good, continue.
        #at this point full string is something like: "4 + 6 + 12 * 4" etc.
        result = str(
            eval(full_string)
        )  # so normally eval is UNSAFE... but since i've dumped regex over the user input i'm pretty confident in the security.
        #print result to chat
        if (no_dice):  #no dice found, warn!
            yield from client.send_message(
                message.channel,
                sh.mention(message) + msg + " = " + result)
        else:  #dice found, just let the users know what's happening
            yield from client.send_message(
                message.channel,
                sh.mention(message) + "wyrzucono " + msg + " (" + full_string +
                "): " + result)
    else:  #print illegal warning.
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "coś tu jest nie teges: " + segment)
예제 #8
0
def c_wyjasnij(client, message):
    result = google(sh.get_args(message))

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak wyników, albo Google się zesrało.")
    else:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + result["desc"] + "\n" + result["url"])
예제 #9
0
def c_wolfram(client, message):
    cw = wolframalpha.Client(wolfram_key)
    res = cw.query(sh.get_args(message, True))

    if not hasattr(res, "results"):
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "nie ma takich rzeczy")
    else:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + next(res.results).text)
예제 #10
0
def c_zwierzaki(client, message):
    tumblr = random.choice(
        ["fluffy-kittens", "cuteanimals", "cutest-critters"])
    result = tumblr_random(tumblr)

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "ZJADŁEM WSZYSTKIE KOTY")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result)
예제 #11
0
def c_google_image_face(client, message):
    for i in range(retry_count):
        result = google(sh.get_args(message, True), "itp:face")

        if not result:
            continue
        else:
            break

    if not result:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + "brzydal")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result["url"])
예제 #12
0
def c_numerki(client, message):
    for i in range(retry_count):
        result = numerki(sh.get_args(message, True))

        if not result:
            continue
        else:
            break

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak hentajca, złe numerki?")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result)
예제 #13
0
def c_youtube(client, message):
    for i in range(retry_count):
        result = yt(sh.get_args(message, True))

        if not result:
            continue
        else:
            break

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak wyników, albo jutub się zesrał.")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result["url"])
예제 #14
0
def c_google_image_gif(client, message):
    for i in range(retry_count):
        result = google(sh.get_args(message, True), "itp:animated")

        if not result:
            continue
        else:
            break

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak wyników, albo Google się zesrało.")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result["url"])
예제 #15
0
def c_kiedy(client, message):
    replies = [
        "o wpół do dziesiątej rano w Polsce", "wczoraj", "jutro",
        "jak przyjdą szwedy", "w trzy dni po premierze Duke Nukem Forever 2",
        "dzień przed końcem świata", "nigdy", "jak dojdą pieniądze",
        "za godzinkę", "kiedy tylko sobie życzysz",
        "gdy przestaniesz zadawać debilne pytania",
        "jak wybiorą czarnego papieża",
        "już za cztery lata, już za cztery lata", "na sylwestrze u P_aula",
        "o 3:33", "o 21:37", "jak Kath napisze magisterkę",
        "jak Dracia zrobi wszystko co musi kiedyś zrobić",
        "jak nevka wróci na Discorda", "jak Paul wejdzie do platyny",
        "jak Fel schudnie", "gdy Aiden zgoli rude kudły",
        "dzień po wybuchowym debiucie Brylanta", "za 12 lat",
        "gdy Martius przestanie pierdolić o ptakach",
        "jak podbiel zje mi dupę", "a co ja jestem, informacja turystyczna?",
        "jak wreszcie wyjebiemy stąd Nargoga",
        "jak Debiru awansuje do seniora", "jak kanau_fela zamknie FBI",
        "już tej nocy w twoim łóżku", "jak Strejlau umrze bo jest stary", "nie"
    ]

    if sh.is_female(message):
        replies = replies + ["gdy wreszcie znajdziesz chłopaka"]
    else:
        replies = replies + ["gdy wreszcie znajdziesz dziewczynę"]

    yield from client.send_message(
        message.channel,
        sh.mention(message) + random.choice(replies))
예제 #16
0
def c_tumblr_r(client, message):
    for i in range(retry_count):
        result = tumblr_random(sh.get_args(message))

        if not result:
            continue
        else:
            break

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "wszystko tylko nie to")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + result)
예제 #17
0
def c_gdzie(client, message):
    prefix = [
        "pod mostem", "w dupie", "na głowie", "na kompie", "w parafii",
        "w koszu", "w fapfolderze", "na rowerze"
    ]
    suffix = [
        "Turambara", "yojca", "Lorda Nargogha", "Rankina", "Kathai",
        "Behemorta", "orgieła", "Stillborna", "Metalusa", "kicka", "podbiela",
        "Sedinusa", "Hakkena", "Tebega", "Sermacieja", "t3trisa", "optiego",
        "Hrabuli", "FaceDancera", "Holiego.Deatha", "Ramzesa", "POLIPa",
        "mateusza(stefana)", "Xysia", "Germanotty", "Berlina", "8azyliszka",
        "Seekera", "Murezora", "RIPa", "Aidena", "Accouna", "Fela", "Dracii",
        "Niziołki", "Mavericka", "P_aula", "Brylanta", "deffika", "Deviusa",
        "Gofra", "JamesaVooa", "Black Shadowa", "emqiego", "nerv4", "Pałkera",
        "Princess Nua", "Rysi", "Shakera", "Artiusa", "Stefana", "Xerbera",
        "gena", "b3rta", "u optiego", "na wydziale elektrycznym",
        "w Kathowicach", "u Kath w piwnicy", "we Wrocławiu", "w Szczecinie",
        "w Brwinowie", "w Warszawie", "w Bogatyni", "w Golubiu-Dobrzynie",
        "w Rzeszowie", "w Krakowie", "w Bydgoszczy",
        "w Magdalence przy stole z pozostałymi zdrajcami",
        "tam gdzie stało ZOMO", "na serwerze Interii", "w Gołodupczynie",
        "w kinie w Berlinie"
    ]
    yield from client.send_message(
        message.channel,
        sh.mention(message) + random.choice(prefix) + " " +
        random.choice(suffix))
예제 #18
0
def c_kurwa(client, message):
    c = sh.get_command(message).lower()[1:]
    e = sh.get_args(message).split(" ")
    ret = ""
    dot = True

    for t in e:
        changecase = False

        if random.random() < 0.2:
            if dot and t[0].isupper():
                ret += c.title() + " "
                if t.istitle():
                    changecase = True
            else:
                ret += c + " "

        if t.endswith("."):
            dot = True
        else:
            dot = False

        if changecase:
            ret += t.lower() + " "
        else:
            ret += t + " "

    yield from client.send_message(message.channel, sh.mention(message) + ret)
예제 #19
0
def c_wyjasnij(client, message):
    for i in range(retry_count):
        result = google(sh.get_args(message, True))

        if not result:
            continue
        else:
            break

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak wyników, albo Google się zesrało.")
    else:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + result["desc"] + "\n" + result["url"])
예제 #20
0
def c_wikipedia(client, message):
    for i in range(retry_count):
        result = google(sh.get_args(message, True) + " site:wikipedia.org")

        if not result:
            continue
        else:
            break

    if not result:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak wyników, albo Wiki się zesrało.")
    else:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + result["text"] + "\n" + result["desc"] +
            "\n" + result["url"])
예제 #21
0
def c_py(client, message):
    """Evaluate a Python expression."""
    if len(sh.get_args(message)) == 0:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "Need an expression to evaluate")
        return

    query = sh.get_args(message)
    uri = BASE_TUMBOLIA_URI + 'py/'
    answer = web.get(uri + web.quote(query))
    if answer:
        #bot.say can potentially lead to 3rd party commands triggering.
        yield from client.send_message(message.channel,
                                       sh.mention(message) + answer)
    else:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + 'Sorry, no result.')
예제 #22
0
def c_manglep(client, message):
    text = sh.get_args(message)
    langs = [
        'auto', 'fr', 'de', 'es', 'it', 'no', 'he', 'la', 'ja', 'en', 'pl'
    ]
    i = 1

    while i < len(langs):
        text = translate(text, langs[i - 1], langs[i])[0]
        yield from client.send_typing(message.channel)
        i += 1

    if text is None:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak wyników, albo Google się zesrało.")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + text)
예제 #23
0
def c_ocen(client, message):
	ocena = random.randint(1, 10)
	doda = ""
	znak = ""
	if ocena < 10 and ocena > 0:
		doda = random.choice(["", ",5", "-", "+"])
	if ocena > 7:
		znak = random.choice(["", "+ <:znak:391940544458391565>", "- Berlin poleca", ""])
	
	yield from client.send_message(message.channel, sh.mention(message) + str(ocena) + doda + "/10 " + znak)
예제 #24
0
def c_czy(client, message):
    response = ""
    responses_yes = [
        "tak", "tak", "na pewno", "jeszcze się pytasz?", "tak (no h**o)",
        "zaiste", "teraz już tak", "a czy papież sra w lesie?",
        "jak najbardziej", "jeszcze jak", "jest możliwe", "owszem",
        "czemu nie", "no w sumie...", "nom", "w rzeczy samej", "na bank",
        "skoro tak mówisz, to nie będę zaprzeczał"
    ]
    responses_no = [
        "nie", "nie", "to mało prawdopodobne", "nie sądzę",
        "tak (żartuję, hehe)", "no chyba cię pambuk opuścił", "raczej nie",
        "jeszcze nie", "gówno prawda", "otóż nie", "niep", "akurat",
        "nawet o tym nie myśl", "bynajmniej", "co ty gadasz", "chyba ty"
    ]
    responses_dunno = [
        "nie wiem", "być może", "hehe))))))))))))))))))", "może kiedyś",
        "jeszcze nie wiem", "daj mi chwilę to się zastanowię",
        "nie wiem, spytaj {}".format(get_random_nickname(message, "genitive")),
        "tego nawet najstarsi górale nie wiedzą", "a jebnąć ci ciupaską?",
        "a co ja jestem, informacja turystyczna?"
    ]

    if sh.is_female(message):
        responses_yes = responses_yes + [
            "tak jest pani kapitan", "trafiłaś w sedno"
        ]
        responses_no = responses_no + ["pani januszko NIE"]
        responses_dunno = responses_dunno + [
            "nie wiem zarobiony jestem przyjdź Pani jutro",
            "co za debilka wymyśla te pytania",
            "nie jesteś za młoda żeby pytać o takie rzeczy?",
            "sama sobie odpowiedz"
        ]
    else:
        responses_yes = responses_yes + [
            "tak jest panie kapitanie", "trafiłeś w sedno"
        ]
        responses_no = responses_no + ["panie januszu NIE"]
        responses_dunno = responses_dunno + [
            "nie wiem zarobiony jestem przyjdź Pan jutro",
            "co za debil wymyśla te pytania",
            "nie jesteś za młody żeby pytać o takie rzeczy?",
            "sam sobie odpowiedz"
        ]

    if random.random() < 0.45:
        response = random.choice(responses_yes)
    elif random.random() < (9 / 11):
        response = random.choice(responses_no)
    else:
        response = random.choice(responses_dunno)

    yield from client.send_message(message.channel,
                                   sh.mention(message) + response)
예제 #25
0
def check_flood(client, message):
    sh.debug("Checking for flood...")
    msg_limit = 5  # messages per channel
    time_limit = 5  # minutes

    if message.channel not in check:
        # channel not tracked yet
        check[message.channel] = {}

    if message.author not in check[message.channel]:
        # author on channel not tracked yet:
        check[message.channel][message.author] = {}
        check[message.channel][message.author]["timestamps"] = []
        check[message.channel][message.author]["warning_issued"] = False

    if len(check[message.channel][message.author]["timestamps"]) < msg_limit:
        # less than limit messages sent
        sh.debug(
            "Message number " +
            str(len(check[message.channel][message.author]["timestamps"]) + 1))
        check[message.channel][message.author]["timestamps"].append(
            time.time())
        return False

    else:
        time_diff = time.time() - check[message.channel][
            message.author]["timestamps"][0]
        if time_diff > (time_limit * 60):
            # message older than time limit
            sh.debug(
                "Message number " + str(msg_limit) + "; deleted timestamp " +
                str(check[message.channel][message.author]["timestamps"][0]),
                message)
            check[message.channel][message.author]["timestamps"].pop(0)
            check[message.channel][message.author]["timestamps"].append(
                time.time())
            check[message.channel][message.author]["warning_issued"] = False
            return False
        else:
            if check[message.channel][
                    message.author]["warning_issued"] == False:
                # scold user for spamming
                sh.debug("This user is spamming!")
                yield from client.send_message(
                    message.channel,
                    sh.mention(message) + "zamknij pizdę przez " +
                    datetime.datetime.utcfromtimestamp(
                        (time_limit * 60) - time_diff).strftime("%Mmin %Ss") +
                    ". Spamuj w <#386148571529084929>")
                check[message.channel][message.author]["warning_issued"] = True
                return True
            else:
                # ...but just once
                sh.debug("Shut him up pls")
                return False
예제 #26
0
def c_wybierz(client, message):
    msg = sh.get_args(message)
    if "," in msg:
        delimiter = ","
    else:
        delimiter = " "

    yield from client.send_message(
        message.channel,
        sh.mention(message) +
        random.choice(list(filter(None, msg.split(delimiter)))).strip())
예제 #27
0
def c_mangle(client, message):
    args = parse_args(sh.get_args(message))
    text = args["msg"]
    langs = [
        args["in_lang"], 'fr', 'de', 'es', 'it', 'no', 'he', 'la', 'ja',
        args["out_lang"]
    ]
    i = 1

    while i < len(langs):
        text = translate(text, langs[i - 1], langs[i])[0]
        yield from client.send_typing(message.channel)
        i += 1

    if text is None:
        yield from client.send_message(
            message.channel,
            sh.mention(message) + "brak wyników, albo Google się zesrało.")
    else:
        yield from client.send_message(message.channel,
                                       sh.mention(message) + text)
예제 #28
0
def c_remind(client, message_obj):
    """Gives you a reminder in the given amount of time."""
    if not sh.get_args(message_obj):
        #yield from client.send_message(message_obj.channel, sh.mention(message_obj) + "no i?")
        return NOLIMIT
    if len(sh.get_args(message_obj).split(" ")) < 2:
        yield from client.send_message(
            message_obj.channel,
            sh.mention(message_obj) + "ale o czym mam przypomnieć?")
        return NOLIMIT
    duration = 0
    message = filter(
        None,
        re.split('(\d+(?:\.\d+)? ?(?:(?i)' + periods + ')) ?',
                 sh.get_args(message_obj))[1:])
    reminder = ''
    stop = False
    for piece in message:
        grp = re.match('(\d+(?:\.\d+)?) ?(.*) ?', piece)
        if grp and not stop:
            length = float(grp.group(1))
            factor = scaling.get(grp.group(2).lower(), 60)
            duration += length * factor
        else:
            reminder = reminder + piece
            stop = True
    if duration == 0:
        yield from client.send_message(
            message_obj.channel,
            sh.mention(message_obj) + "i może frytki do tego?")
        return

    if duration % 1:
        duration = int(duration) + 1
    else:
        duration = int(duration)
    timezone = get_timezone(None, None, None, message_obj.author.mention,
                            message_obj.channel.id)
    yield from create_reminder(client, message_obj, duration, reminder,
                               timezone)
예제 #29
0
def c_komu(client, message):
    yield from client.send_message(
        message.channel,
        sh.mention(message) + random.choice([
            "mi", "tobie", "nikomu", "Turambarowi", "yojcu",
            "Lordowi Nargoghowi", "Rankinowi", "Kathajce", "Behemortowi",
            "orgiełowi", "Stillbornowi", "Metalusowi", "kickowi", "podbielowi",
            "Sedinusowi", "Hakkenowi", "Tebegowi", "Sermaciejowi", "t3trisowi",
            "optiemu", "Hrabuli", "FaceDancerowi", "Holiemu.Deathowi",
            "lghostowi", "POLIPowi", "mateuszowi(stefanowi)", "Xysiowi",
            "Germanotcie", "Berlinowi", "8azyliszkowi", "Seekerowi",
            "Murezorowi", "R1Powi", "Aidenowi", "Trepliev", "Accounowi",
            "Śćasowi"
        ]))
예제 #30
0
def create_reminder(client, message_obj, duration, message, tz):
    t = int(time.time()) + duration
    reminder = (message_obj.channel.id, message_obj.author.mention, message)
    try:
        client.rdb[t].append(reminder)
    except KeyError:
        client.rdb[t] = [reminder]

    dump_database(client.rfn, client.rdb)

    if duration >= 60:
        remind_at = datetime.fromtimestamp(t)
        timef = format_time(None, None, tz, message_obj.author.mention,
                            message_obj.channel.id, remind_at)

        yield from client.send_message(
            message_obj.channel,
            sh.mention(message_obj) + 'dobra, przypomnę w dniu %s' % timef)
    else:
        yield from client.send_message(
            message_obj.channel,
            sh.mention(message_obj) +
            'dobra, przypomnę za %s sekund' % duration)