def game(): wrong_guesses = session['wrong_guesses'] wrong_letters = session['wrong_letters'] word = session['word'] clue = session['clue'] letter = request.form['letter'] if wrong_letters.find(letter) != -1: # When a wrong letter was gussed that has already been guessed return render_template('game.html', letter=letter, wrong_letters=wrong_letters, clue=' '.join(clue), hangman=hangman(wrong_guesses)) elif wrong_guesses >= 5: # Hangman guy has been hanged.. return render_template('end.html', end=cow.milk_random_cow('you not so smart, the word was ' + word)) else: # Something else letter_index = word.find(letter) if letter_index != -1: # Correct letter guessed for i in range(len(word)): if letter == word[i]: clue[i] = letter if ''.join(clue) == word: # Word fully guessed return render_template('end.html', end=cow.milk_random_cow('you smart, the word was ' + word)) else: # Word not fully guessed yet return render_template('game.html', letter=letter, wrong_letters=wrong_letters, clue=' '.join(clue), hangman=hangman(wrong_guesses)) else: # Wrong letter guessed session['wrong_letters'] += letter session['wrong_guesses'] += 1 wrong_guesses = session['wrong_guesses'] wrong_letters = session['wrong_letters'] return render_template('game.html', letter=letter, wrong_letters=wrong_letters, clue=' '.join(clue), hangman=hangman(wrong_guesses))
def cow_style(msg): """ cow_style()风格使用cowpy模块生成随机ASCII码艺 术字符,夸张地表现文本 """ msg1 = cow.milk_random_cow(msg) msg2 = cow.milk_random_cow(msg1) return msg2
def _do_cowsay(message=None, messages=None, cowfiles=None, cowsay_bin=None, color=(0, 0, 255)): if message: msg = cow.milk_random_cow(message) else: msg = cow.milk_random_cow("carpe diem dude!") log.debug(msg) img = _convert_msg_to_image(msg, color) return img
def print_invite(conf: YouwolEnvironment): print(f"""{Fore.GREEN} Configuration loaded successfully {Style.RESET_ALL}. """) print(conf) msg = cow.milk_random_cow(f""" All good, you can now browse to http://localhost:{conf.http_port}/applications/@youwol/platform/latest """) print(msg)
async def cowsay(self, ctx): await ctx.trigger_typing() messages = ctx.channel.history(limit=1, before=ctx.message) async for message_to_edit in messages: to_edit = message_to_edit.content random_cow = cow.milk_random_cow(to_edit) edited = '```' + re.sub('```', '', random_cow) + '```' await ctx.send(edited) await ctx.message.delete()
async def handle_message(self, client, message, state): if message.content.lower().startswith(self.signal): msg = message.content.replace(self.signal + " ", "") msg = cow.milk_random_cow(msg) msg = "```" + msg + "```" await message.channel.send(msg)
def cli(cowsay, icanhazdad, github, reddit): if icanhazdad: dadjoke = random.choice(get_icanhazdadjoke()) elif github: dadjoke = random.choice(get_wesbos_dad_jokes()) elif reddit: dadjoke = random.choice(get_post_reddit('DadJokes')) else: dadjoke = random.choice(get_wesbos_dad_jokes()) if cowsay: click.echo(cow.milk_random_cow(dadjoke)) else: click.echo(dadjoke)
def cowpy(self, al_argList, astr_text): """ Place the <astr_text> in a "cowpy" bubble with an optional character spec. Default character is 'tux'. """ d_ret = {'status': False, 'result': "", 'error': ""} if len(al_argList): str_char = al_argList[0] else: str_char = 'moose' try: if str_char != 'random': cow_cls = cow.get_cow(str_char) betsy = cow_cls() d_ret['result'] = betsy.milk(astr_text) else: d_ret['result'] = cow.milk_random_cow(astr_text) d_ret['status'] = True except Exception as e: d_ret['error'] = str(e) + " character not found" return d_ret
def muu(verbose=False): result = cow.milk_random_cow("Hello world") return result
msg = cheese.milk("my witty mesage, i'm dead") print(msg) # Get a cow by name cow_cls = cow.get_cow('moose') cheese = cow_cls() msg = cheese.milk("Cow by name is moose") print(msg) # Create a Cow with a thought bubble, a tongue, and dead eyes cheese = cow.Moose(thoughts=True, tongue=True, eyes='dead') msg = cheese.milk("My witty mesage with several attributes") print(msg) # Create a random cow with a one-line message msg = cow.milk_random_cow("A random message for fun") print(msg) # Create a random cow with a multi-line message msg = cow.milk_random_cow("\n".join([ "A random multi-line message:", "1. for fun", "2. for fun", "3. and for fun" ])) print(msg) # all the eye options eye_options = cow.eye_options() print(eye_options)
msg = cheese.milk("My witty mesage, with tongue") print(msg) # Create a Cow with dead eyes cheese = cow.Moose(eyes='dead') msg = cheese.milk("my witty mesage, i'm dead") print(msg) # Get a cow by name cow_cls = cow.get_cow('moose') cheese = cow_cls() msg = cheese.milk("Cow by name is moose") print(msg) # Create a Cow with a thought bubble, a tongue, and dead eyes cheese = cow.Moose(thoughts=True, tongue=True, eyes='dead') msg = cheese.milk("My witty mesage with several attributes") print(msg) # Create a random cow with a message msg = cow.milk_random_cow("A random message for fun") print(msg) # all the eye options eye_options = cow.eye_options() print(eye_options) # all the cowacter options cow_options = cow.cow_options() print(cow_options)
def api_entry(): message = cow.milk_random_cow( "Random message for the Entrypoint to the App") print(message) return message
def cow_style(msg): msg1 = cow.milk_random_cow(msg) msg2 = cow.milk_random_cow(msg1) return msg2
def cow_style(msg): msg = cow.milk_random_cow(msg) return msg
from dadjokes.sources import get_wesbos_dad_jokes from cowpy import cow import click import random import sys joke: str = random.choice(get_wesbos_dad_jokes()) joke = joke.replace('"', "'") if len(sys.argv) > 1: click.echo(cow.milk_random_cow(joke)) else: click.echo(joke)
def cow_style(msg): return cow.milk_random_cow(msg)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Time : 2020/4/20 10:51 AM # @Author : w8ay # @File : test_banner.py import random from colorama.ansi import code_to_chars from cowpy.cow import get_cow, milk_random_cow # for i in range(100): from lib.core.common import random_colorama cow = get_cow() msg = "w13scan v1.0" for i in range(50): sfw = True s = milk_random_cow(msg, sfw=sfw) # print(s) # print(s) test = "aa\t\tabccc" s = random_colorama(s) print(s)
return parent.selftext if type(parent) is praw.objects.Submission else parent.body if __name__ == '__main__': for comment in praw.helpers.comment_stream(r, 'all', limit=None, verbosity=0): match = directive.search(comment.body) if match: id = comment.id document = {'_id': id} if comments_collection.find_one(document): continue content = get_parent_content(comment) actor_name = match.group('actor') if actor_name: actor = cow.get_cow(actor_name.strip()) actor = None if actor == 'default' else actor() else: actor = None if type(actor) is not str and actor is not None: message = actor.milk(content) else: message = cow.milk_random_cow(content) comment.reply(sign(indent(message))) comments_collection.insert(document)
def commands(room, line): try: # parse code a, b = line.split("]", 1) b = b[1:] #remove leading space _, name = a.split("[") #test function if ((b == "!test\n") and ("mars" in a)): if room == "mutants": send(room, "we out here") if room == "star fish": send(room, "beep") #listing of available commands if b == "!commands\n": if room == "mutants": send( room, '!addquote *** !quote !req *** !t *** !hi !art !art ***\n!news !news *** !dev *** !clap *** !def *** !sandwich !diagnose !oracle !slap [user]\n!movie *** !listmovies !sonnet !chuck !dog !qotd !haiku !wiki !advice !link' ) if room == "star fish": send( room, '!addquote *** !quote !req *** !t *** !hi !art !art ***\n!news !news *** !dev *** !clap *** !def *** !sandwich !diagnose !oracle !slap ***\n!movie *** !listmovies !sonnet !chuck !dog !qotd !haiku !wiki !advice !link !startup' ) #request features, appends to local requests.log if b.startswith("!req "): send(room, "thank you very much") req = open("requests.log", "a+") req.write(line) req.close() print "request added:" print b #intestination --- get console output from list users, find if it contains user #user found -- shall i intestinate? (yes/no) if b.startswith("!intestinate "): _, usr = b.split(1) send(room, "/me") #thanks if b == "thanks\n": send(room, "you too") #quote database (add specific users) if b.startswith("!addquote "): if room == "mutants": quotes = open("quotes.log", "a+") if room == "star fish": quotes = open("starquotes.log", "a+") _, q = b.split(' ', 1) quotes.write(q) quotes.close() send(room, "quote added!") if b == "!quote\n": if room == "mutants": lines = open('quotes.log').read().splitlines() if room == "star fish": lines = open('starquotes.log').read().splitlines() randquote = random.choice(lines) send(room, randquote) #link aggregator if "http" in b: c = b.find("http") #twitter feed if b == "!tweet\n": if room == "mutants": tweets = api.home_timeline(count=1) for t in tweets: send(room, t.text) if b.startswith("!t "): acct = b[3:].strip() works = 1 try: tweets = api.user_timeline(id=acct, count=500, tweet_mode='extended') except tweepy.error.TweepError: send(room, "u f****d up") works = 0 if works == 1: tt = True while tt == True: tt = False t = random.choice(tweets) try: text = t.extended_tweet["full_text"] except AttributeError: try: text = t.text except AttributeError: text = t.full_text if ("RT @" not in text) and (not text.startswith("@")): send(room, text) else: tt = True if b == "!usa\n": usalist = [ "USA", "USAUSA", "USAUSAUSA", "USAUSAUSAUSA", "U\nS\nA\n", "USA USA USA USA USA", "UUU\nSSS\nAAA" ] for _ in range(0, 10): c = random.randint(0, 6) send(room, usalist[c]) time.sleep(1) if b == "!rand\n": if room == "mutants": tweets = api.user_timeline(count=50) t = random.choice(tweets) send(room, t.text) if re.match('!rand [0-9]', b): if room == "mutants": num = int(b[6]) tweets = api.user_timeline(count=500) for _ in range(0, num): t = random.choice(tweets) send(room, t.text) time.sleep(1.5) #dgd link spammer if ((b == "!dgd\n") and ("(o" in a)): links = open('dgd.txt').read().splitlines() randlink = random.choice(links) send(room, randlink) #hi test if b == "!hi\n": send(room, u"hi, %s 🐙" % name) if b == "!benny\n": send(room, "benny") #definitions if b.startswith("!def "): f = find(b[5:].strip()) send(room, f) #news api if b.startswith("!news "): query = b[6:].strip() allnews = newsapi.get_everything(q=query, page_size=50) length = len(allnews['articles']) if length != 0: if length > 2: num = random.randint(0, length - 1) elif length == 1: num = 0 send(room, allnews['articles'][num]['title']) time.sleep(1) send(room, allnews['articles'][num]['description']) time.sleep(1) send(room, allnews['articles'][num]['url']) else: send(room, "none found") if b == "!news\n": topnews = newsapi.get_top_headlines(sources='bbc-news', page_size=50) num = random.randint(0, topnews['totalResults'] - 1) send(room, topnews['articles'][num]['title']) time.sleep(1) send(room, topnews['articles'][num]['description']) time.sleep(1) send(room, topnews['articles'][num]['url']) #deviantart if b.startswith("!dev "): query = b[5:].strip() allnews = newsapi.get_everything(q=query, page_size=50, domains='deviantart.com') length = len(allnews['articles']) if length != 0: if length > 2: num = random.randint(0, length - 1) else: num = 0 if num > 0: send(room, allnews['articles'][num]['title']) time.sleep(1) send(room, allnews['articles'][num]['description']) time.sleep(1) send(room, allnews['articles'][num]['url']) else: send(room, "none found") #wikiart retrieval if b == "!art\n": #random from most popular url = urllib2.urlopen( 'https://www.wikiart.org/en/App/Painting/MostViewedPaintings?randomSeed=123&json=2' ) urldict = json.load(url) r = random.randint(0, len(urldict) - 1) title = urldict[r]['title'] artist = urldict[r]['artistName'] image = urldict[r]['image'] year = urldict[r]['completitionYear'] image = image.replace('!Large.jpg', '') send(room, title + ' [' + artist + ', ' + str(year) + ']') send(room, image) if b.startswith("!art "): query = b[5:].strip() query = query.replace(' ', '%20') url = urllib2.urlopen( 'https://www.wikiart.org/en/search/%s/1?json=2&PageSize=600' % query) urldict = json.load(url) if (len(urldict) != 0): if (len(urldict) == 1): r = 0 elif (len(urldict) > 1): r = random.randint(0, len(urldict) - 1) title = urldict[r]['title'] artist = urldict[r]['artistName'] image = urldict[r]['image'] year = urldict[r]['completitionYear'] image = image.replace('!Large.jpg', '') send(room, title + ' [' + artist + ', ' + str(year) + ']') send(room, image) else: send(room, "none found") #clap emoji converter if b.startswith("!clap ") or b.startswith(" "): if b.startswith(" ") and not b.startswith(" "): text = b[2:] else: text = b[6:] claptext = "👏 " + text.replace(' ', ' 👏 ').strip('\n') + ' 👏' send(room, claptext) if b.startswith("!horn "): text = b[6:] claptext = "📣 " + text.replace(' ', ' 📣 ').strip('\n') + ' 📣' send(room, claptext) #gross if b == "!brap\n": send(room, "BRRRRAAAAAAAP") #youtube link title if (('watch?v' in b) or ('youtu.be' in b)) and ('~' not in b): if room == "mutants": last_id_tants = video_id(b) if room == "star fish": last_id_star = video_id(b) title = yt_title(video_id(b)) if title != '': send(room, title) if b == "!y\n": if room == "mutants": lastid = last_id_tants if room == "star fish": lastid = last_id_star if lastid != '': send(room, yt_title(lastid)) if b == "!sandwich\n": wich = random.choice(corp.foods.sandwiches['sandwiches']) send(room, wich['name']) time.sleep(0.5) send(room, wich['description']) time.sleep(0.5) if wich['origin'] != '': send(room, 'Origin: ' + wich['origin']) if b == "!diagnose\n": options = [ "good news! you have {disease} from that {animal} in {country}", "i'm sorry, you've contracted {disease} from a {animal} in {country}" ] sentence = random.choice(options) _disease = random.choice(corp.medicine.diagnoses['codes'])['desc'] _disease = _disease[0].lower() + _disease[1:] _animal = random.choice(corp.animals.common['animals']) _country = random.choice(corp.geography.countries['countries']) send( room, sentence.format(disease=_disease, animal=_animal, country=_country)) if b == "!oracle\n": oracles = open('oracle.txt').read().splitlines() randlink = random.choice(oracles) send(room, randlink) if b.startswith("!slap "): victim = b[6:].strip("\n") verbs = ['slaps', 'smacks', 'bludgeons', 'uppercuts'] _verb = random.choice(verbs) _obj = random.choice(corp.objects.objects['objects']) if _obj[0] in ['a', 'e', 'i', 'o', 'u']: _article = 'an' else: _article = 'a' send( room, '%s %s %s with %s %s.' % (name, _verb, victim, _article, _obj)) if b == "!g****e\n": lines = open("g****e.txt").read().splitlines() for l in lines: send(room, l) if ("elma" in b) and ("elma" not in name) and ("tant" not in name): if room == "mutants": send(room, "it's Elma now") #request muvies if b.startswith("!movie "): send(room, "i added it thanks") if room == "mutants": req = open("muvies.log", "a+") elif room == "star fish": req = open("starmuvies.log", "a+") req.write(b[7:]) req.close() print "movie added:" print b if b == "!listmovies\n": if room == "mutants": ms = open("muvies.log").read().splitlines() elif room == "star fish": ms = open("starmuvies.log").read().splitlines() send(room, "movie list:") for m in ms: send(room, m) if b == "!sonnet\n": r = requests.get( "http://poetrydb.org/author,linecount/Shakespeare;14/title,lines" ) r = r.json() sonnet = random.choice(r) for l in sonnet['lines']: send(room, l) if b == "!chuck\n": r = requests.get("https://api.chucknorris.io/jokes/random") r = r.json() send(room, r['value']) if b == "!dog\n": r = requests.get("https://dog.ceo/api/breeds/image/random") r = r.json() send(room, r['message']) if b == "!qotd\n": r = requests.get("https://favqs.com/api/qotd") r = r.json() send(room, '%s - %s' % (r['quote']['body'], r['quote']['author'])) if ((sylco(b) > 4) and (sylco(b) < 12) and ("tant" not in name)) or b.startswith(" "): if (random.randint(0, 300) == 2) or (b.startswith(" ")): if (room == "mutants") or (room == "star fish"): word = b.rsplit(None, 1)[-1].lower() print word rhymes = pronouncing.rhymes(word) print rhymes if room == "mutants": slines = open("mutants.log").read().splitlines() if room == "star fish": slines = open("star fish.log").read().splitlines() random.shuffle(slines) for sline in slines: lastword = sline.rsplit(None, 1)[-1] if lastword in rhymes: if sylco(sline.rsplit(']', 1)[-1][1:]) == sylco(b): send(room, "ay") time.sleep(1) rhyming = sline.split(']', 1)[-1] print rhyming send(room, rhyming.strip('\n')) time.sleep(1) send(room, "ay") break #log haiku generator if b == "!haiku\n": slines = open("%s.log" % room).read().splitlines() random.shuffle(slines) line1 = '' line2 = '' line3 = '' for sline in slines: text = sline.rsplit(']', 1)[-1][1:] if (sylco(text) == 5) and ('http' not in text): if line1 == '': line1 = text else: line3 = text break for sline in slines: text = sline.rsplit(']', 1)[-1][1:] if (sylco(text) == 7) and ('http' not in text): line2 = text send(room, line1) time.sleep(1) send(room, line2) time.sleep(1) send(room, line3) if b == "!wiki\n": list = wiki.random() page = wiki.page(title=list) send(room, page.url) if b == "!advice\n": r = requests.get("http://api.adviceslip.com/advice") r = r.json() send(room, r['slip']['advice']) if b == "!link\n": slines = open("%s.log" % room).read().splitlines() random.shuffle(slines) for line in slines: links = '' f = re.search("(?P<url>https?://[^\s]+)", line) if f: f = f.group('url') send(room, f) break if b == "!startup\n": r = requests.get("http://itsthisforthat.com/api.php?text") r = r.text send(room, r) #4chan random topic if b.startswith("!chan "): boardname = b[6:].strip('\n') board = basc_py4chan.Board(boardname) threads = board.get_all_thread_ids() threadid = random.choice(threads) thread = board.get_thread(threadid) images = thread.files() #topic = thread.topic #imgfile = topic.first_file #print topic.comment #print imgfile.file_url for f in thread.files(): send(room, f) break #twitter search if b.startswith("!twit "): query = b[6:].strip('\n') tweets = api.search(query) while 1: tweet = random.choice(tweets) if 'RT' not in tweet.text: if tweet.text[0] != '@': break send(room, tweet.text) if b == "!fortune\n": r = requests.get( "http://fortunecookieapi.herokuapp.com/v1/fortunes?limit=1000&skip=&page=" ) i = random.randint(0, 100) r = r.json() send(room, r[i]['message']) if b.startswith("!horoscope "): sign = b[11:].strip("\n") r = requests.get("https://www.horoscopes-and-astrology.com/json") r = r.json() horo, _ = r['dailyhoroscope'][sign.capitalize()].split('<', 1) send(room, horo) if b == "!iching\n": num = random.randint(1, 64) url = "http://reoxy.org/iching/{}.html" r = requests.get(url.format(num)) html = BeautifulSoup(r.text) name = html.title.text[10:] char = unichr(19903 + num) send(room, u"{} - {} {}".format(char, name, url.format(num))) if b == "!joke\n": r = requests.get( "https://08ad1pao69.execute-api.us-east-1.amazonaws.com/dev/random_ten" ) r = r.json() while 1: joke = random.choice(r) if joke['type'] == 'general': break send(room, joke['setup']) time.sleep(5) send(room, joke['punchline']) if b == "!trump\n": r = requests.get("https://api.tronalddump.io/random/quote") r = r.json() send(room, r['value']) if b.startswith("!gif "): query = b[5:].strip("\n") r = requests.get( "https://api.gfycat.com/v1/gfycats/search?search_text={}". format(query)) r = r.json() gfy = random.choice(r['gfycats']) send(room, gfy['title']) send(room, gfy['webpUrl']) if b.startswith("!num "): num = b[5:].strip("\n") r = requests.get("http://numbersapi.com/{}".format(num)) send(room, r.text) if b.startswith("!cowsay "): say = b[8:].strip("\n") msg = cow.milk_random_cow(say) send(room, msg) except Exception: print sys.exc_info()[0] print "i broke\n" print traceback.print_exc()
msg = cheese.milk("my witty mesage, i'm dead") print(msg) # Get a cow by name cow_cls = cow.get_cow('moose') cheese = cow_cls() msg = cheese.milk("Cow by name is moose") print(msg) # Create a Cow with a thought bubble, a tongue, and dead eyes cheese = cow.Moose(thoughts=True, tongue=True, eyes='dead') msg = cheese.milk("My witty mesage with several attributes") print(msg) # Create a random cow with a one-line message msg = cow.milk_random_cow("A random message for fun") print(msg) # Create a random cow with a multi-line message msg = cow.milk_random_cow("\n".join([ "A random multi-line message:", "1. for fun", "2. for fun", "3. and for fun" ])) print(msg) # all the eye options eye_options = cow.eye_options() print(eye_options) # all the cowacter options cow_options = cow.cow_options()
# ------------------------------------------------ # # cowpy # https://github.com/jeffbuttars/cowpy # # ------------------------------------------------ from cowpy import cow print(cow.Moose().milk("wahahahha")) print(cow.Moose(eyes='dead', tongue=True).milk("wahahahha")) print(cow.Moose(eyes='dead', tongue=True, thoughts=True).milk("wahahahha")) print(cow.milk_random_cow("agadkjfasldkj")) # list options print(cow.cow_options()) print(cow.eye_options()) # ------------------------------------------------ # # pyFiglet # https://github.com/pwaller/pyfiglet # fonts: http://www.figlet.org/examples.html
def banner(): msg = "w13scan v{}".format(VERSION) sfw = True s = milk_random_cow(msg, sfw=sfw) dataToStdout(random_colorama(s) + "\n\n")