Intended to be used with ii.
$ cd 'ii/irc.some.net/#channel'
$ tail -f out | python3 -u ~/duckhunter2.py >> in
References:
#!/usr/bin/env python3 | |
from sys import stdin | |
from random import choice | |
from time import sleep | |
duck_tail = "・゜゜・。。・゜゜" | |
duck = ["\_o< ", "\_O< ", "\_0< ", "\_\u00f6< ", "\_\u00f8< ", "\_\u00f3< "] | |
duck_noise = ["QUACK!", "FLAP FLAP!", "quack!"] | |
bang_miss = [ | |
"WHOOSH! You missed the duck completely!", | |
"Your gun jammed!", | |
"Better luck next time.", | |
"WTF!? Who are you Dick Cheney?" ] | |
bef_miss = [ | |
"The duck didn't want to be friends, maybe next time.", | |
"Well this is awkward, the duck needs to think about it.", | |
"The duck said no, maybe bribe it with some pizza? Ducks love pizza don't they?", | |
"Who knew ducks could be so picky?"] | |
again = " You can try again in 7 seconds." | |
def clean_duck(duck): | |
return duck.replace(' \u200b ', '').replace('\u200b', '').rstrip() | |
def quacks(duck): | |
for noise in duck_noise: | |
if duck.endswith(noise): | |
return True | |
return False | |
def act(): | |
print(choice([".befriend", ".bang"])) | |
def delay(secs): | |
# override to pass for speedy testing | |
sleep(secs) | |
for line in stdin: | |
if quacks(clean_duck(line)): | |
delay(1) | |
act() | |
if line.rstrip().endswith(again): | |
delay(7) | |
act() |
Intended to be used with ii.
$ cd 'ii/irc.some.net/#channel'
$ tail -f out | python3 -u ~/duckhunter2.py >> in
References: