38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
from irc3.plugins.command import command
|
|
from irc3.plugins.cron import cron
|
|
import irc3
|
|
import cowsay
|
|
from random import randint
|
|
|
|
@irc3.plugin
|
|
class Plugin:
|
|
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
|
|
@command(permission='view')
|
|
def cowsay(self, mask, target, args):
|
|
"""cowsay character message to say. characters: beavis cheese daemon cow dragon ghostbusters kitty meow milk pig stegosaurus stimpy trex turkey turtle tux. e.g. ?cowsay cow moo, no character selection will randomize character choice. e.g. ?cowsay moo
|
|
%%cowsay <message>...
|
|
"""
|
|
message = args.get('<message>')
|
|
character = ' '.join(message).split()[0].lower()
|
|
_character = ''
|
|
for _ in list(cowsay.char_names):
|
|
if _ == character:
|
|
_character = _
|
|
|
|
message = ' '.join(message).split()
|
|
|
|
if _character == '':
|
|
character = list(cowsay.char_names)[randint(0,len(cowsay.char_names))]
|
|
message = ' '.join(message)
|
|
else:
|
|
character = _character
|
|
message = str(' '.join(message)).replace(_character,'').strip()
|
|
|
|
msg = cowsay.get_output_string(character,message).splitlines()
|
|
for _ in msg:
|
|
self.bot.privmsg(target,_)
|