def cowsay(): helpmsg = ''' Welcom to cow-as-as-service. We support following commands: help display help info say TEXT draw a cow saying TEXT if no TEXT is given, and file named '-' is present, it will be used ''' if not 'command' in request.args or request.args['command'] not in ('help', 'say'): abort(make_response("Command missing or invalid. Cow-as-a-service supportos only following commands: help, say", 422)) command = request.args['command'] arguments = request.args.getlist('arg') if command == 'help': return Response(helpmsg, mimetype='text/plain') elif command == 'say': if (not arguments and '-' not in request.files) or len(arguments) > 1: return Response(helpmsg, mimetype='text/plain') else: if arguments: text = arguments[0] else: text = request.files['-'].stream.read().decode('utf8') return Response(cow.get_cow()().milk(msg=text), mimetype='text/plain')
async def univsaye(cowmsg): """ For .cowsay module, userbot wrapper for cow which says things. """ if not cowmsg.text[0].isalpha() and cowmsg.text[0] not in ("/", "#", "@", "!"): arg = cowmsg.pattern_match.group(1).lower() text = cowmsg.pattern_match.group(2) if arg == "cow": arg = "default" if arg not in cow.COWACTERS: return cheese = cow.get_cow(arg) cheese = cheese() await cowmsg.edit(f"`{cheese.milk(text).replace('`', '´')}`")
async def cowsay_(message: Message): """cowsay""" arg = message.matches[0].group(1).lower() text = message.matches[0].group(2) if arg == "cow": arg = "default" if arg not in cow.COWACTERS: await message.err("cowacter not found!") return cheese = cow.get_cow(arg) cheese = cheese() await message.edit(f"`{cheese.milk(text).replace('`', '´')}`")
async def univsaye(event): """For .cowsay module, uniborg wrapper for cow which says things.""" if event.text[0].isalpha() or event.text[0] in ("/", "#", "@", "!"): return arg = event.pattern_match.group(1).lower() text = event.pattern_match.group(2) if arg == "cow": arg = "default" if arg not in cow.COWACTERS: return await edit_or_reply(event, "`This Character is not Supported`") cheese = cow.get_cow(arg) cheese = cheese() await edit_or_reply(event, f"`{cheese.milk(text).replace('`', '´')}`")
async def cowsay(event: NewMessage.Event) -> None: """ Create messages with various animals and other creatures. `{prefix}cowsay Hello!` """ arg = event.matches[0].group(1).lower() text = event.matches[0].group(2) if arg == "cow": arg = "default" if arg not in cow.COWACTERS: return cheese = cow.get_cow(arg) cheese = cheese() await event.answer(f"<code>{cheese.milk(text)}</code>", parse_mode="html")
async def univsaye(cowmsg): if cowmsg.is_group: if not (await is_register_admin(cowmsg.input_chat, cowmsg.message.sender_id)): await cowmsg.reply("") return """ For .cowsay module, uniborg wrapper for cow which says things. """ if not cowmsg.text[0].isalpha() and cowmsg.text[0] not in ("#", "@"): arg = cowmsg.pattern_match.group(1).lower() text = cowmsg.pattern_match.group(2) if arg == "cow": arg = "default" if arg not in cow.COWACTERS: return cheese = cow.get_cow(arg) cheese = cheese() await cowmsg.reply(f"`{cheese.milk(text).replace('`', '´')}`")
async def think(cowmsg): """ For .cowthink module, userbot wrapper for cow which thinks of things. """ if len(e.text.split(" ")) < 2: return splits = e.text.split(" ") arg = splits[1] tch = splits if arg == "cow": arg = "default" elif arg not in cow.COWACTERS: arg = "default" else: tch = splits[1:] cheese = cow.get_cow(arg) cheese = cheese(thoughts=True) await cowmsg.edit(f"`{cheese.milk(' '.join(tch)).replace('`', '´')}`")
def cowsay(message): ext = message.text.split(' ', 1) arg = ext[0] arg = arg[1:arg.find('say')] textx = message.reply_to_message if textx and textx.text: text = textx.text elif len(ext) > 1: text = ext[1] else: edit(message, '`Komut kullanımı hatalı.`') return if arg == "cow" or arg not in cow.COWACTERS: arg = "default" cheese = cow.get_cow(arg) cheese = cheese() edit(message, f"`{cheese.milk(text).replace('`', '´')}`")
def cowsay(message): ext = message.text.split(' ', 1) arg = parse_cmd(ext[0]) arg = arg[:arg.find('say')] textx = message.reply_to_message if textx and textx.text: text = textx.text elif len(ext) > 1: text = ext[1] else: edit(message, f'`{get_translation("wrongCommand")}`') return if arg == 'cow' or arg not in cow.COWACTERS: arg = 'default' cheese = cow.get_cow(arg) cheese = cheese() edit(message, f"`{cheese.milk(text).replace('`', '´')}`")
async def univsaye(cowmsg): """ .cowsay komutu bir şeyler söyleyen inek yapar """ ext = cowmsg.text.split(' ', 1) arg = ext[0] arg = arg[1:arg.find('say')] textx = await cowmsg.get_reply_message() if textx and textx.text: text = textx.text elif len(ext) > 1: text = ext[1] else: await cowmsg.edit("`Komut kullanımı hatalı.`") return if arg == "cow" or arg not in cow.COWACTERS: arg = "default" cheese = cow.get_cow(arg) cheese = cheese() await cowmsg.edit(f"`{cheese.milk(text).replace('`', '´')}`")
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 say(text, name='default'): """Return some cowsayed text.""" cowacter = cow.get_cow(name)() return cowacter.milk(text)
cheese = cow.Moose(thoughts=True) msg = cheese.milk("My witty mesage, with thought") print(msg) # Create a Cow with a tongue cheese = cow.Moose(tongue=True) 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 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([
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)
#!/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)
def test_server_sends_qs_back(): response = requests.get('http://127.0.0.1:3000/cow?msg=hello') assert response.status_code == 200 assert response.text == cow.get_cow()().milk('hello')