Browse Source

a few bugfixes and added !coin (which should be removed), license change

master
jcao219 13 years ago
parent
commit
b85a4f47c0
  1. 24
      LICENSE
  2. 10
      decorators.py
  3. 69
      wolfgame.py

24
LICENSE

@ -1,16 +1,8 @@
Copyright (c) 2011 Jimmy Cao Copyright (c) 2011, Jimmy Cao
Permission is hereby granted, free of charge, to any person obtaining a copy All rights reserved.
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
furnished to do so, subject to the following conditions: Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
The above copyright notice and this permission notice shall be included in THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

10
decorators.py

@ -1,3 +1,13 @@
# Copyright (c) 2011, Jimmy Cao
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
# Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from oyoyo.parse import parse_nick from oyoyo.parse import parse_nick
import botconfig import botconfig

69
wolfgame.py

@ -1,19 +1,11 @@
# Copyright (c) 2011 Jimmy Cao # Copyright (c) 2011, Jimmy Cao
# Permission is hereby granted, free of charge, to any person obtaining a copy # All rights reserved.
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is # Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
# furnished to do so, subject to the following conditions: # Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
# The above copyright notice and this permission notice shall be included in # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
from oyoyo.parse import parse_nick from oyoyo.parse import parse_nick
import var import var
@ -315,16 +307,17 @@ def fjoin(cli, nick, chan, rest):
if not rest.strip(): if not rest.strip():
join(cli, nick, chan, "") join(cli, nick, chan, "")
for a in re.split("\s+",rest): for a in re.split(" +",rest):
a = a.strip() a = a.strip()
if not a: if not a:
continue continue
ull = [u.lower() for u in var.USERS] ull = [u.lower() for u in var.USERS]
if a.lower() not in ull: if a.lower() not in ull:
if not is_fake_nick(a) and not noticed: if not is_fake_nick(a):
cli.msg(chan, nick+(": You may only fjoin fake people "+ if not noticed: # important
"or people in this channel for now.")) cli.msg(chan, nick+(": You may only fjoin fake people "+
noticed = True "or people in this channel for now."))
noticed = True
continue continue
if not is_fake_nick(a): if not is_fake_nick(a):
a = var.USERS[ull.index(a.lower())] a = var.USERS[ull.index(a.lower())]
@ -335,7 +328,7 @@ def fjoin(cli, nick, chan, rest):
@cmd("fleave","fquit","fdel", admin_only=True) @cmd("fleave","fquit","fdel", admin_only=True)
def fleave(cli, nick, chan, rest): def fleave(cli, nick, chan, rest):
for a in re.split("\s+",rest): for a in re.split(" +",rest):
a = a.strip() a = a.strip()
if not a: if not a:
continue continue
@ -359,7 +352,7 @@ def fstart(cli, nick, chan, rest):
@cmd("chankick", admin_only=True) @cmd("chankick", admin_only=True)
def chankick(cli, nick, chan, rest): def chankick(cli, nick, chan, rest):
rest = rest.split(" ", 1) rest = re.split(" +", rest, 1)
if not rest[0]: if not rest[0]:
cli.notice(nick, "Invalid syntax for this command.") cli.notice(nick, "Invalid syntax for this command.")
return return
@ -1018,7 +1011,7 @@ def vote(cli, nick, chan, rest):
return return
pl = var.list_players() pl = var.list_players()
pl_l = [x.strip().lower() for x in pl] pl_l = [x.strip().lower() for x in pl]
rest = re.split("\s+",rest)[0].strip().lower() rest = re.split(" +",rest)[0].strip().lower()
if rest in pl_l: if rest in pl_l:
if nick in var.WOUNDED: if nick in var.WOUNDED:
cli.msg(chan, ("{0}: You are wounded and resting, "+ cli.msg(chan, ("{0}: You are wounded and resting, "+
@ -1089,7 +1082,7 @@ def shoot(cli, nick, chan, rest):
elif not var.GUNNERS[nick]: elif not var.GUNNERS[nick]:
cli.msg(nick, "You don't have any more bullets.") cli.msg(nick, "You don't have any more bullets.")
return return
victim = re.split("\s+",rest)[0].strip().lower() victim = re.split(" +",rest)[0].strip().lower()
if not victim: if not victim:
cli.notice(nick, "Not enough parameters") cli.notice(nick, "Not enough parameters")
return return
@ -1152,7 +1145,7 @@ def kill(cli, nick, rest):
if var.PHASE != "night": if var.PHASE != "night":
cli.msg(nick, "You may only kill people at night.") cli.msg(nick, "You may only kill people at night.")
return return
victim = re.split("\s+",rest)[0].strip().lower() victim = re.split(" +",rest)[0].strip().lower()
if not victim: if not victim:
cli.msg(nick, "Not enough parameters") cli.msg(nick, "Not enough parameters")
return return
@ -1194,7 +1187,7 @@ def guard(cli, nick, rest):
if var.PHASE != "night": if var.PHASE != "night":
cli.msg(nick, "You may only protect people at night.") cli.msg(nick, "You may only protect people at night.")
return return
victim = re.split("\s+",rest)[0].strip().lower() victim = re.split(" +",rest)[0].strip().lower()
if not victim: if not victim:
cli.msg(nick, "Not enough parameters") cli.msg(nick, "Not enough parameters")
return return
@ -1231,7 +1224,7 @@ def observe(cli, nick, rest):
if var.PHASE != "night": if var.PHASE != "night":
cli.msg(nick, "You may only transform into a crow at night.") cli.msg(nick, "You may only transform into a crow at night.")
return return
victim = re.split("\s+", rest)[0].strip().lower() victim = re.split(" +", rest)[0].strip().lower()
if not victim: if not victim:
cli.msg(nick, "Not enough parameters") cli.msg(nick, "Not enough parameters")
return return
@ -1272,7 +1265,7 @@ def investigate(cli, nick, rest):
if nick in var.INVESTIGATED: if nick in var.INVESTIGATED:
cli.msg(nick, "You may only investigate one person per round.") cli.msg(nick, "You may only investigate one person per round.")
return return
victim = re.split("\s+", rest)[0].strip().lower() victim = re.split(" +", rest)[0].strip().lower()
if not victim: if not victim:
cli.msg(nick, "Not enough parameters") cli.msg(nick, "Not enough parameters")
return return
@ -1312,7 +1305,7 @@ def hvisit(cli, nick, rest):
cli.msg(nick, ("You are already spending the night "+ cli.msg(nick, ("You are already spending the night "+
"with \u0002{0}\u0002.").format(var.HVISITED[nick])) "with \u0002{0}\u0002.").format(var.HVISITED[nick]))
return return
victim = re.split("\s+",rest)[0].strip().lower() victim = re.split(" +",rest)[0].strip().lower()
if not victim: if not victim:
cli.msg(nick, "Not enough parameters") cli.msg(nick, "Not enough parameters")
return return
@ -1341,7 +1334,7 @@ def is_fake_nick(who):
@cmd("frole", admin_only=True) @cmd("frole", admin_only=True)
def frole(cli, nick, chan, rest): def frole(cli, nick, chan, rest):
rst = re.split("\s+",rest) rst = re.split(" +",rest)
if len(rst) < 2: if len(rst) < 2:
cli.msg(chan, "The syntax is incorrect.") cli.msg(chan, "The syntax is incorrect.")
who = rst.pop(0).strip() who = rst.pop(0).strip()
@ -1384,7 +1377,7 @@ def frole(cli, nick, chan, rest):
@cmd("force", admin_only=True) @cmd("force", admin_only=True)
def forcepm(cli, nick, chan, rest): def forcepm(cli, nick, chan, rest):
rst = re.split("\s+",rest) rst = re.split(" +",rest)
if len(rst) < 2: if len(rst) < 2:
cli.msg(chan, "The syntax is incorrect.") cli.msg(chan, "The syntax is incorrect.")
return return
@ -1427,7 +1420,7 @@ def see(cli, nick, rest):
if nick in var.SEEN: if nick in var.SEEN:
cli.msg(nick, "You may only have one vision per round.") cli.msg(nick, "You may only have one vision per round.")
return return
victim = re.split("\s+",rest)[0].strip().lower() victim = re.split(" +",rest)[0].strip().lower()
pl = var.list_players() pl = var.list_players()
pll = [x.lower() for x in pl] pll = [x.lower() for x in pl]
if not victim: if not victim:
@ -1772,7 +1765,7 @@ def game(cli, nick, chan, rest):
return return
rest = rest.strip().lower() rest = rest.strip().lower()
if rest: if rest:
if cgamemode(cli, *re.split("\s+",rest)): if cgamemode(cli, *re.split(" +",rest)):
var.SETTINGS_CHANGE_REQUESTER = nick var.SETTINGS_CHANGE_REQUESTER = nick
cli.msg(chan, ("\u0002{0}\u0002 has changed the "+ cli.msg(chan, ("\u0002{0}\u0002 has changed the "+
"game settings successfully. To "+ "game settings successfully. To "+
@ -1953,7 +1946,7 @@ def show_admins(cli, nick, chan, rest):
@cmd("admin", owner_only=True) @cmd("admin", owner_only=True)
def make_admin(cli, nick, chan, rest): def make_admin(cli, nick, chan, rest):
"""Temporarily""" """Temporarily"""
rst = re.split("\s+",rest) rst = re.split(" +",rest)
if len(rst) < 1: if len(rst) < 1:
cli.msg(chan, "The syntax is incorrect.") cli.msg(chan, "The syntax is incorrect.")
return return
@ -1974,3 +1967,9 @@ def revroles(cli, nick, chan, rest):
#TODO: make this and other functions debug-mode only #TODO: make this and other functions debug-mode only
@cmd("coin")
def coin(cli, nick, chan, rest):
"""Ugh"""
cli.msg(chan, "\2{0}\2 tosses a coin into the air...".format(nick))
cli.msg(chan, "The coin lands on \2{0}\2.".format("heads" if random.random() < 0.5 else "tails"))

Loading…
Cancel
Save