Browse Source

somewhat modified the anti-flood, and fixed some howl differences

master
jcao219 14 years ago
parent
commit
fa593d0db1
  1. 11
      oyoyo/client.py
  2. 2
      var.py
  3. 8
      wolfgame.py

11
oyoyo/client.py

@ -104,7 +104,7 @@ class IRCClient(object): @@ -104,7 +104,7 @@ class IRCClient(object):
self.blocking = True
self.lock = threading.RLock()
self.tokenbucket = TokenBucket(3, 1.73)
self.tokenbucket = TokenBucket(28, 1.73)
self.last_messaged = ""
self.__dict__.update(kwargs)
@ -145,6 +145,9 @@ class IRCClient(object): @@ -145,6 +145,9 @@ class IRCClient(object):
msg = bytes(" ", "utf_8").join(bargs)
logging.info('---> send "{0}"'.format(msg))
while not self.tokenbucket.consume(1):
pass
self.socket.send(msg + bytes("\r\n", "utf_8"))
def connect(self):
@ -226,12 +229,6 @@ class IRCClient(object): @@ -226,12 +229,6 @@ class IRCClient(object):
raise SystemExit # lets exit
def msg(self, user, msg):
for line in msg.split('\n'):
if user == self.last_messaged:
while not self.tokenbucket.consume(1):
pass
else: # ?
while not self.tokenbucket.consume(0.37):
pass
self.send("PRIVMSG", user, ":{0}".format(line))
self.last_messaged = user
privmsg = msg # Same thing

2
var.py

@ -2,7 +2,7 @@ PING_WAIT = 300 # Seconds @@ -2,7 +2,7 @@ PING_WAIT = 300 # Seconds
MINIMUM_WAIT = 60
EXTRA_WAIT = 20
MAXIMUM_WAITED = 2 # limit for amount of !wait's
MAX_SHOTS = 2
SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given
MAX_PLAYERS = 30
DRUNK_SHOTS_MULTIPLIER = 3
NIGHT_TIME_LIMIT = 90

8
wolfgame.py

@ -22,6 +22,7 @@ import logging @@ -22,6 +22,7 @@ import logging
import sys
import os
import imp
import math
COMMANDS = {}
PM_COMMANDS = {}
@ -1761,9 +1762,10 @@ def start(cli, nick, chan, rest): @@ -1761,9 +1762,10 @@ def start(cli, nick, chan, rest):
for gnr in random.sample(possible, len(var.ROLES["gunner"])):
if var.ROLES["village drunk"] == gnr:
var.GUNNERS[gnr] = var.DRUNK_SHOTS_MULTIPLIER * var.MAX_SHOTS
var.GUNNERS[gnr] = (var.DRUNK_SHOTS_MULTIPLIER *
math.ceil(var.SHOTS_MULTIPLIER * len(var.list_players())))
else:
var.GUNNERS[gnr] = var.MAX_SHOTS
var.GUNNERS[gnr] = math.ceil(var.SHOTS_MULTIPLIER * len(var.list_players()))
del var.ROLES["gunner"]
var.ROLES["villager"] = villagers
@ -2160,7 +2162,7 @@ if botconfig.DEBUG_MODE: @@ -2160,7 +2162,7 @@ if botconfig.DEBUG_MODE:
if len(rolargs) == 2 and len(rolargs[1]) < 7 and rolargs[1].isdigit():
var.GUNNERS[who] = int(rolargs[1])
else:
var.GUNNERS[who] = var.MAX_SHOTS
var.GUNNERS[who] = math.ceil(var.SHOTS_MULTIPLIER * len(var.list_players()))
if who not in pl:
var.ROLES["villager"].append(who)
elif rol == "cursed":

Loading…
Cancel
Save