Fix a few niggles
This commit is contained in:
parent
20339d0a64
commit
2211cb0542
2 changed files with 21 additions and 18 deletions
|
@ -190,10 +190,14 @@ 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):
|
||||||
command_prefix = event["target"].get_setting("command-prefix",
|
if event["is_channel"]:
|
||||||
|
command_prefix = event["target"].get_setting("command-prefix",
|
||||||
event["server"].get_setting(
|
event["server"].get_setting(
|
||||||
"command-prefix",
|
"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(
|
||||||
|
|
|
@ -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
|
||||||
|
@ -213,8 +212,8 @@ class Module(object):
|
||||||
channel.set_user_setting(uid, "ducks-befriended", total_befriended)
|
channel.set_user_setting(uid, "ducks-befriended", total_befriended)
|
||||||
|
|
||||||
msg = "Aww! %s befriended a duck! You've befriended %s ducks in %s!" \
|
msg = "Aww! %s befriended a duck! You've befriended %s ducks in %s!" \
|
||||||
% ( Utils.bold(nick), Utils.bold(total_befriended),
|
% (Utils.bold(nick), Utils.bold(total_befriended),
|
||||||
Utils.bold(channel.name) )
|
Utils.bold(channel.name))
|
||||||
|
|
||||||
event["stdout"].write(msg)
|
event["stdout"].write(msg)
|
||||||
|
|
||||||
|
@ -244,8 +243,8 @@ class Module(object):
|
||||||
channel.set_user_setting(uid, "ducks-shot", total_shot)
|
channel.set_user_setting(uid, "ducks-shot", total_shot)
|
||||||
|
|
||||||
msg = "Pow! %s shot a duck! You've shot %s ducks in %s!" \
|
msg = "Pow! %s shot a duck! You've shot %s ducks in %s!" \
|
||||||
% ( Utils.bold(nick), Utils.bold(total_shot),
|
% (Utils.bold(nick), Utils.bold(total_shot),
|
||||||
Utils.bold(channel.name) )
|
Utils.bold(channel.name))
|
||||||
|
|
||||||
event["stdout"].write(msg)
|
event["stdout"].write(msg)
|
||||||
|
|
||||||
|
@ -286,8 +285,8 @@ class Module(object):
|
||||||
cf = channel_friends
|
cf = channel_friends
|
||||||
|
|
||||||
msg = "%s ducks killed (%s in %s), and %s ducks befriended (%s in %s)" \
|
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(tp), Utils.bold(cp), Utils.bold(channel),
|
||||||
Utils.bold(tf), Utils.bold(cf), Utils.bold(channel) )
|
Utils.bold(tf), Utils.bold(cf), Utils.bold(channel))
|
||||||
|
|
||||||
event["stdout"].write(Utils.bold(nick) + ": " + msg)
|
event["stdout"].write(Utils.bold(nick) + ": " + msg)
|
||||||
|
|
||||||
|
@ -351,8 +350,8 @@ class Module(object):
|
||||||
for i in range(0, length):
|
for i in range(0, length):
|
||||||
nick = Utils.prevent_highlight(friend_nicks[i])
|
nick = Utils.prevent_highlight(friend_nicks[i])
|
||||||
build.append("%s (%s)" \
|
build.append("%s (%s)" \
|
||||||
% ( Utils.bold(nick),
|
% (Utils.bold(nick),
|
||||||
friend_ducks[i])
|
friend_ducks[i])
|
||||||
)
|
)
|
||||||
|
|
||||||
sentence += ", ".join(build)
|
sentence += ", ".join(build)
|
||||||
|
|
Loading…
Reference in a new issue