Skip to content

Instantly share code, notes, and snippets.

@jpouellet
Last active November 14, 2023 20:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpouellet/abfe6273cc090b10b44726bb7f0a9e44 to your computer and use it in GitHub Desktop.
Save jpouellet/abfe6273cc090b10b44726bb7f0a9e44 to your computer and use it in GitHub Desktop.
A script to hunt ducks on IRC. Don't mind me...
#!/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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment