Browse Source

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

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

24
LICENSE

@ -1,16 +1,8 @@ @@ -1,16 +1,8 @@
Copyright (c) 2011 Jimmy Cao
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
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.
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.

10
decorators.py

@ -1,3 +1,13 @@ @@ -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
import botconfig

63
wolfgame.py

@ -1,19 +1,11 @@ @@ -1,19 +1,11 @@
# Copyright (c) 2011 Jimmy Cao
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# 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.
# 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
import var
@ -315,13 +307,14 @@ def fjoin(cli, nick, chan, rest): @@ -315,13 +307,14 @@ def fjoin(cli, nick, chan, rest):
if not rest.strip():
join(cli, nick, chan, "")
for a in re.split("\s+",rest):
for a in re.split(" +",rest):
a = a.strip()
if not a:
continue
ull = [u.lower() for u in var.USERS]
if a.lower() not in ull:
if not is_fake_nick(a) and not noticed:
if not is_fake_nick(a):
if not noticed: # important
cli.msg(chan, nick+(": You may only fjoin fake people "+
"or people in this channel for now."))
noticed = True
@ -335,7 +328,7 @@ def fjoin(cli, nick, chan, rest): @@ -335,7 +328,7 @@ def fjoin(cli, nick, chan, rest):
@cmd("fleave","fquit","fdel", admin_only=True)
def fleave(cli, nick, chan, rest):
for a in re.split("\s+",rest):
for a in re.split(" +",rest):
a = a.strip()
if not a:
continue
@ -359,7 +352,7 @@ def fstart(cli, nick, chan, rest): @@ -359,7 +352,7 @@ def fstart(cli, nick, chan, rest):
@cmd("chankick", admin_only=True)
def chankick(cli, nick, chan, rest):
rest = rest.split(" ", 1)
rest = re.split(" +", rest, 1)
if not rest[0]:
cli.notice(nick, "Invalid syntax for this command.")
return
@ -1018,7 +1011,7 @@ def vote(cli, nick, chan, rest): @@ -1018,7 +1011,7 @@ def vote(cli, nick, chan, rest):
return
pl = var.list_players()
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 nick in var.WOUNDED:
cli.msg(chan, ("{0}: You are wounded and resting, "+
@ -1089,7 +1082,7 @@ def shoot(cli, nick, chan, rest): @@ -1089,7 +1082,7 @@ def shoot(cli, nick, chan, rest):
elif not var.GUNNERS[nick]:
cli.msg(nick, "You don't have any more bullets.")
return
victim = re.split("\s+",rest)[0].strip().lower()
victim = re.split(" +",rest)[0].strip().lower()
if not victim:
cli.notice(nick, "Not enough parameters")
return
@ -1152,7 +1145,7 @@ def kill(cli, nick, rest): @@ -1152,7 +1145,7 @@ def kill(cli, nick, rest):
if var.PHASE != "night":
cli.msg(nick, "You may only kill people at night.")
return
victim = re.split("\s+",rest)[0].strip().lower()
victim = re.split(" +",rest)[0].strip().lower()
if not victim:
cli.msg(nick, "Not enough parameters")
return
@ -1194,7 +1187,7 @@ def guard(cli, nick, rest): @@ -1194,7 +1187,7 @@ def guard(cli, nick, rest):
if var.PHASE != "night":
cli.msg(nick, "You may only protect people at night.")
return
victim = re.split("\s+",rest)[0].strip().lower()
victim = re.split(" +",rest)[0].strip().lower()
if not victim:
cli.msg(nick, "Not enough parameters")
return
@ -1231,7 +1224,7 @@ def observe(cli, nick, rest): @@ -1231,7 +1224,7 @@ def observe(cli, nick, rest):
if var.PHASE != "night":
cli.msg(nick, "You may only transform into a crow at night.")
return
victim = re.split("\s+", rest)[0].strip().lower()
victim = re.split(" +", rest)[0].strip().lower()
if not victim:
cli.msg(nick, "Not enough parameters")
return
@ -1272,7 +1265,7 @@ def investigate(cli, nick, rest): @@ -1272,7 +1265,7 @@ def investigate(cli, nick, rest):
if nick in var.INVESTIGATED:
cli.msg(nick, "You may only investigate one person per round.")
return
victim = re.split("\s+", rest)[0].strip().lower()
victim = re.split(" +", rest)[0].strip().lower()
if not victim:
cli.msg(nick, "Not enough parameters")
return
@ -1312,7 +1305,7 @@ def hvisit(cli, nick, rest): @@ -1312,7 +1305,7 @@ def hvisit(cli, nick, rest):
cli.msg(nick, ("You are already spending the night "+
"with \u0002{0}\u0002.").format(var.HVISITED[nick]))
return
victim = re.split("\s+",rest)[0].strip().lower()
victim = re.split(" +",rest)[0].strip().lower()
if not victim:
cli.msg(nick, "Not enough parameters")
return
@ -1341,7 +1334,7 @@ def is_fake_nick(who): @@ -1341,7 +1334,7 @@ def is_fake_nick(who):
@cmd("frole", admin_only=True)
def frole(cli, nick, chan, rest):
rst = re.split("\s+",rest)
rst = re.split(" +",rest)
if len(rst) < 2:
cli.msg(chan, "The syntax is incorrect.")
who = rst.pop(0).strip()
@ -1384,7 +1377,7 @@ def frole(cli, nick, chan, rest): @@ -1384,7 +1377,7 @@ def frole(cli, nick, chan, rest):
@cmd("force", admin_only=True)
def forcepm(cli, nick, chan, rest):
rst = re.split("\s+",rest)
rst = re.split(" +",rest)
if len(rst) < 2:
cli.msg(chan, "The syntax is incorrect.")
return
@ -1427,7 +1420,7 @@ def see(cli, nick, rest): @@ -1427,7 +1420,7 @@ def see(cli, nick, rest):
if nick in var.SEEN:
cli.msg(nick, "You may only have one vision per round.")
return
victim = re.split("\s+",rest)[0].strip().lower()
victim = re.split(" +",rest)[0].strip().lower()
pl = var.list_players()
pll = [x.lower() for x in pl]
if not victim:
@ -1772,7 +1765,7 @@ def game(cli, nick, chan, rest): @@ -1772,7 +1765,7 @@ def game(cli, nick, chan, rest):
return
rest = rest.strip().lower()
if rest:
if cgamemode(cli, *re.split("\s+",rest)):
if cgamemode(cli, *re.split(" +",rest)):
var.SETTINGS_CHANGE_REQUESTER = nick
cli.msg(chan, ("\u0002{0}\u0002 has changed the "+
"game settings successfully. To "+
@ -1953,7 +1946,7 @@ def show_admins(cli, nick, chan, rest): @@ -1953,7 +1946,7 @@ def show_admins(cli, nick, chan, rest):
@cmd("admin", owner_only=True)
def make_admin(cli, nick, chan, rest):
"""Temporarily"""
rst = re.split("\s+",rest)
rst = re.split(" +",rest)
if len(rst) < 1:
cli.msg(chan, "The syntax is incorrect.")
return
@ -1974,3 +1967,9 @@ def revroles(cli, nick, chan, rest): @@ -1974,3 +1967,9 @@ def revroles(cli, nick, chan, rest):
#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