Merge pull request #19 from dngfx/master
I have no idea why ducks.py is in here. Google.py update.
This commit is contained in:
commit
dacf8998eb
4 changed files with 136 additions and 40 deletions
|
@ -38,11 +38,11 @@ class Out(object):
|
||||||
class StdOut(Out):
|
class StdOut(Out):
|
||||||
def prefix(self):
|
def prefix(self):
|
||||||
return "%s%s%s" % (Utils.color(Utils.COLOR_GREEN),
|
return "%s%s%s" % (Utils.color(Utils.COLOR_GREEN),
|
||||||
self.module_name, Utils.FONT_RESET)
|
self.module_name, Utils.FONT_COLOR)
|
||||||
class StdErr(Out):
|
class StdErr(Out):
|
||||||
def prefix(self):
|
def prefix(self):
|
||||||
return "%s!%s%s" % (Utils.color(Utils.COLOR_RED),
|
return "%s!%s%s" % (Utils.color(Utils.COLOR_RED),
|
||||||
self.module_name, Utils.FONT_RESET)
|
self.module_name, Utils.FONT_COLOR)
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
@ -190,12 +190,24 @@ class Module(object):
|
||||||
event["stdout"].write("Commands: %s" % ", ".join(help_available))
|
event["stdout"].write("Commands: %s" % ", ".join(help_available))
|
||||||
|
|
||||||
def usage(self, event):
|
def usage(self, event):
|
||||||
|
if event["is_channel"]:
|
||||||
|
command_prefix = event["target"].get_setting("command-prefix",
|
||||||
|
event["server"].get_setting(
|
||||||
|
"command-prefix",
|
||||||
|
"!"))
|
||||||
|
else:
|
||||||
|
command_prefix = ""
|
||||||
|
|
||||||
|
|
||||||
command = event["args_split"][0].lower()
|
command = event["args_split"][0].lower()
|
||||||
if command in self.events.on("received").on(
|
if command in self.events.on("received").on(
|
||||||
"command").get_children():
|
"command").get_children():
|
||||||
hooks = self.events.on("received").on("command").on(command).get_hooks()
|
hooks = self.events.on("received").on("command").on(command).get_hooks()
|
||||||
if hooks and "usage" in hooks[0].kwargs:
|
if hooks and "usage" in hooks[0].kwargs:
|
||||||
event["stdout"].write("Usage: %s %s" % (command, hooks[0].kwargs["usage"]))
|
event["stdout"].write("Usage: %s%s %s" % (command_prefix,
|
||||||
|
command,
|
||||||
|
hooks[0].kwargs[
|
||||||
|
"usage"]))
|
||||||
else:
|
else:
|
||||||
event["stderr"].write("No usage help available for %s" % command)
|
event["stderr"].write("No usage help available for %s" % command)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import random
|
import random
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from time import time
|
from time import time
|
||||||
|
import EventManager
|
||||||
|
|
||||||
import Utils
|
import Utils
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ DUCK_MESSAGE_RARE = ["beep boop!", "QUACK QUACK QUACK QUACK QUACK!!", "HONK!",
|
||||||
DUCK_MINIMUM_MESSAGES = 10
|
DUCK_MINIMUM_MESSAGES = 10
|
||||||
DUCK_MINIMUM_UNIQUE = 3
|
DUCK_MINIMUM_UNIQUE = 3
|
||||||
|
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
|
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
@ -21,14 +23,11 @@ class Module(object):
|
||||||
self.events = events
|
self.events = events
|
||||||
|
|
||||||
events.on("received.command.bef").hook(self.befriend,
|
events.on("received.command.bef").hook(self.befriend,
|
||||||
priority=1,
|
priority=EventManager.PRIORITY_HIGH,
|
||||||
help="Befriend a "
|
help="Befriend a duck!")
|
||||||
"duck!")
|
|
||||||
events.on("received.command.bang").hook(self.shoot,
|
events.on("received.command.bang").hook(self.shoot,
|
||||||
priority=1,
|
priority=EventManager.PRIORITY_HIGH,
|
||||||
help="Shoot a "
|
help="Shoot a duck! Meanie." )
|
||||||
"duck! "
|
|
||||||
"Meanie.", )
|
|
||||||
# events.on("received").on("command").on("decoy").hook(self.set_decoy,
|
# events.on("received").on("command").on("decoy").hook(self.set_decoy,
|
||||||
# help="Be a
|
# help="Be a
|
||||||
# sneaky fellow
|
# sneaky fellow
|
||||||
|
@ -53,9 +52,8 @@ class Module(object):
|
||||||
|
|
||||||
events.on("new.channel").hook(self.new_channel)
|
events.on("new.channel").hook(self.new_channel)
|
||||||
|
|
||||||
|
|
||||||
events.on("received").on("message").on("channel").hook(
|
events.on("received").on("message").on("channel").hook(
|
||||||
self.channel_message, priority=2)
|
self.channel_message)
|
||||||
|
|
||||||
for server in self.bot.servers.values():
|
for server in self.bot.servers.values():
|
||||||
for channel in server.channels.values():
|
for channel in server.channels.values():
|
||||||
|
@ -63,6 +61,7 @@ class Module(object):
|
||||||
|
|
||||||
def new_channel(self, event):
|
def new_channel(self, event):
|
||||||
self.bootstrap(event["channel"])
|
self.bootstrap(event["channel"])
|
||||||
|
|
||||||
def bootstrap(self, channel):
|
def bootstrap(self, channel):
|
||||||
self.init_game_var(channel)
|
self.init_game_var(channel)
|
||||||
# getset
|
# getset
|
||||||
|
@ -212,11 +211,11 @@ class Module(object):
|
||||||
|
|
||||||
channel.set_user_setting(uid, "ducks-befriended", total_befriended)
|
channel.set_user_setting(uid, "ducks-befriended", total_befriended)
|
||||||
|
|
||||||
event["stdout"].write(
|
msg = "Aww! %s befriended a duck! You've befriended %s ducks in %s!" \
|
||||||
"Aww! " + nick + " befriended a duck! You've befriended " +
|
% (Utils.bold(nick), Utils.bold(total_befriended),
|
||||||
Utils.bold(
|
Utils.bold(channel.name))
|
||||||
str(total_befriended)) + " ducks in " + Utils.bold(
|
|
||||||
channel.name) + "!")
|
event["stdout"].write(msg)
|
||||||
|
|
||||||
self.clear_ducks(channel)
|
self.clear_ducks(channel)
|
||||||
|
|
||||||
|
@ -243,10 +242,11 @@ class Module(object):
|
||||||
|
|
||||||
channel.set_user_setting(uid, "ducks-shot", total_shot)
|
channel.set_user_setting(uid, "ducks-shot", total_shot)
|
||||||
|
|
||||||
event["stdout"].write(
|
msg = "Pow! %s shot a duck! You've shot %s ducks in %s!" \
|
||||||
"Pow! " + nick + " shot a duck! You've shot " + Utils.bold(
|
% (Utils.bold(nick), Utils.bold(total_shot),
|
||||||
str(total_shot)) + " ducks in " + Utils.bold(
|
Utils.bold(channel.name))
|
||||||
channel.name) + "!")
|
|
||||||
|
event["stdout"].write(msg)
|
||||||
|
|
||||||
self.clear_ducks(channel)
|
self.clear_ducks(channel)
|
||||||
|
|
||||||
|
@ -279,11 +279,16 @@ class Module(object):
|
||||||
else:
|
else:
|
||||||
total_poached += number
|
total_poached += number
|
||||||
|
|
||||||
event["stdout"].write(
|
tf = total_friends
|
||||||
nick + ": " + str(total_poached) + " ducks killed (" + str(
|
tp = total_poached
|
||||||
channel_poached) + " in " + channel + "), and " + str(
|
cp = channel_poached
|
||||||
total_friends) + " ducks befriended (" + str(
|
cf = channel_friends
|
||||||
channel_friends) + " in " + channel + ")")
|
|
||||||
|
msg = "%s ducks killed (%s in %s), and %s ducks befriended (%s in %s)" \
|
||||||
|
% (Utils.bold(tp), Utils.bold(cp), Utils.bold(channel),
|
||||||
|
Utils.bold(tf), Utils.bold(cf), Utils.bold(channel))
|
||||||
|
|
||||||
|
event["stdout"].write(Utils.bold(nick) + ": " + msg)
|
||||||
|
|
||||||
def duck_enemies(self, event):
|
def duck_enemies(self, event):
|
||||||
the_enemy = event["server"].find_all_user_channel_settings("ducks-shot")
|
the_enemy = event["server"].find_all_user_channel_settings("ducks-shot")
|
||||||
|
@ -303,16 +308,18 @@ class Module(object):
|
||||||
enemy_nicks.append(user)
|
enemy_nicks.append(user)
|
||||||
enemy_ducks.append(enemies)
|
enemy_ducks.append(enemies)
|
||||||
|
|
||||||
sentence = "Most Notorious Users -- "
|
sentence = Utils.bold("Duck Wranglers: ")
|
||||||
|
build = []
|
||||||
|
|
||||||
length = len(enemy_nicks) if len(enemy_nicks) < 11 else 11
|
length = len(enemy_nicks) if len(enemy_nicks) < 8 else 8
|
||||||
|
|
||||||
for i in range(0, length):
|
for i in range(0, length):
|
||||||
sentence += enemy_nicks[i] + " (" + str(enemy_ducks[i]) + ")"
|
nick = Utils.prevent_highlight(enemy_nicks[i])
|
||||||
if i < 10:
|
build.append("%s (%s)" \
|
||||||
sentence += ", "
|
% (Utils.bold(nick),
|
||||||
|
enemy_ducks[i]))
|
||||||
|
|
||||||
sentence = sentence[0:-2]
|
sentence += ", ".join(build)
|
||||||
|
|
||||||
event["stdout"].write(sentence)
|
event["stdout"].write(sentence)
|
||||||
|
|
||||||
|
@ -335,15 +342,18 @@ class Module(object):
|
||||||
friend_nicks.append(user)
|
friend_nicks.append(user)
|
||||||
friend_ducks.append(friends)
|
friend_ducks.append(friends)
|
||||||
|
|
||||||
sentence = "Friendliest Users -- "
|
sentence = Utils.bold("Duck Friends: ")
|
||||||
|
|
||||||
length = len(friend_nicks) if len(friend_nicks) < 11 else 11
|
length = len(friend_nicks) if len(friend_nicks) < 8 else 8
|
||||||
|
build = []
|
||||||
|
|
||||||
for i in range(0, length):
|
for i in range(0, length):
|
||||||
sentence += friend_nicks[i] + " (" + str(friend_ducks[i]) + ")"
|
nick = Utils.prevent_highlight(friend_nicks[i])
|
||||||
if i < 10:
|
build.append("%s (%s)" \
|
||||||
sentence += ", "
|
% (Utils.bold(nick),
|
||||||
|
friend_ducks[i])
|
||||||
|
)
|
||||||
|
|
||||||
sentence = sentence[0:-2]
|
sentence += ", ".join(build)
|
||||||
|
|
||||||
event["stdout"].write(sentence)
|
event["stdout"].write(sentence)
|
||||||
|
|
|
@ -22,8 +22,8 @@ class Module(object):
|
||||||
"num": 1, "gl": "gb"}, json=True)
|
"num": 1, "gl": "gb"}, json=True)
|
||||||
if page:
|
if page:
|
||||||
if "items" in page and len(page["items"]):
|
if "items" in page and len(page["items"]):
|
||||||
event["stdout"].write(page["items"][0][
|
event["stdout"].write("(" + Utils.bold(phrase) + ") " \
|
||||||
"link"])
|
+ page["items"][0]["link"])
|
||||||
else:
|
else:
|
||||||
event["stderr"].write("No results found")
|
event["stderr"].write("No results found")
|
||||||
else:
|
else:
|
||||||
|
|
74
modules/shakespeare.py
Normal file
74
modules/shakespeare.py
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
import random
|
||||||
|
import Utils
|
||||||
|
|
||||||
|
INSULT_INTRO = ["Thou art a", "Ye", "Thou", "Thy", "Thee"]
|
||||||
|
|
||||||
|
INSULT_PART_1 = ["artless", "bawdy", "beslubbering", "bootless", "churlish",
|
||||||
|
"cockered", "clouted", "craven", "currish", "dankish",
|
||||||
|
"dissembling",
|
||||||
|
"droning", "errant", "fawning", "fobbing", "forward", "frothy",
|
||||||
|
"gleeking", "goatish", "gorbellied", "impertinent",
|
||||||
|
"infectious",
|
||||||
|
"jarring", "loggerheaded", "lumpish", "mammering", "mangled",
|
||||||
|
"mewling", "paunchy", "pribbling", "puking", "puny",
|
||||||
|
"qualling",
|
||||||
|
"rank", "reeky", "roguish", "ruttish", "saucy", "spleeny",
|
||||||
|
"spongy",
|
||||||
|
"surly", "tottering", "unmuzzled", "vain", "venomed",
|
||||||
|
"villainous",
|
||||||
|
"warped", "wayward", "weedy", "yeast"]
|
||||||
|
|
||||||
|
INSULT_PART_2 = ["base-court", "bat-fowling", "beef-witted", "beetle-headed",
|
||||||
|
"boil-brained", "clapper-clawed", "clay-brained",
|
||||||
|
"common-kissing",
|
||||||
|
"crook-pated", "dismal-dreaming", "dizzy-eyed", "doghearted",
|
||||||
|
"dread-bolted", "earth-vexing", "elf-skinned", "fat-kidneyed",
|
||||||
|
"fen-sucked", "flap-mouthed", "fly-bitten", "folly-fallen",
|
||||||
|
"fool-born", "full-gorged", "guts-griping", "half-faced",
|
||||||
|
"hasty-witted", "hedge-born", "hell-hated", "idle-headed",
|
||||||
|
"ill-breeding", "ill-nurtured", "knotty-pated", "milk-livered",
|
||||||
|
"motley-minded", "onion-eyed", "plume-plucked", "pottle-deep",
|
||||||
|
"pox-marked", "reeling-ripe", "rough-hewn", "rude-growing",
|
||||||
|
"rump-fed", "shard-borne", "sheep-biting", "spur-galled",
|
||||||
|
"swag-bellied", "tardy-gaited", "tickle-brained",
|
||||||
|
"toad-spotted",
|
||||||
|
"unchin-snouted", "weather-bitten"]
|
||||||
|
|
||||||
|
INSULT_PART_3 = ["apple-john", "baggage", "barnacle", "bladder", "boar-pig",
|
||||||
|
"bugbear", "bum-bailey", "canker-blossom", "clack-dish",
|
||||||
|
"clotpole",
|
||||||
|
"coxcomb", "codpiece", "death-token", "dewberry",
|
||||||
|
"flap-dragon",
|
||||||
|
"flax-wench", "flirt-gill", "foot-licker", "fustilarian",
|
||||||
|
"giglet",
|
||||||
|
"gudgeon", "haggard", "harpy", "hedge-pig", "horn-beast",
|
||||||
|
"hugger-mugger", "joithead", "lewdster", "lout", "maggot-pie",
|
||||||
|
"malt-worm", "mammet", "measle", "minnow", "miscreant",
|
||||||
|
"moldwarp",
|
||||||
|
"mumble-news", "nut-hook", "pigeon-egg", "pignut", "puttock",
|
||||||
|
"pumpion", "ratsbane", "scut", "skainsmate", "strumpet",
|
||||||
|
"varlot",
|
||||||
|
"vassal", "whey-face", "wagtail"]
|
||||||
|
|
||||||
|
|
||||||
|
class Module(object):
|
||||||
|
|
||||||
|
def __init__(self, bot, events, exports):
|
||||||
|
self.bot = bot
|
||||||
|
self.events = events
|
||||||
|
|
||||||
|
events.on("received").on("command").on("insult").hook(
|
||||||
|
self.dispense_insult)
|
||||||
|
|
||||||
|
def dispense_insult(self, event):
|
||||||
|
insult = [random.choice(INSULT_INTRO), random.choice(INSULT_PART_1),
|
||||||
|
random.choice(INSULT_PART_2), random.choice(INSULT_PART_3)]
|
||||||
|
|
||||||
|
insult = " ".join(insult)
|
||||||
|
target = ""
|
||||||
|
|
||||||
|
if event["args_split"]:
|
||||||
|
target = Utils.bold(event["server"].get_user(
|
||||||
|
event["args_split"][0]).nickname) + ", "
|
||||||
|
|
||||||
|
event["stdout"].write(target + insult + "!")
|
Loading…
Reference in a new issue