Add random fortunes

This commit is contained in:
nyuszika7h 2015-03-28 17:15:16 +01:00
parent fd8d0bbdf7
commit 3bcb188b32
2 changed files with 15 additions and 0 deletions

View File

@ -3598,6 +3598,20 @@ def transition_day(cli, gameid=0):
"https://i.imgur.com/b8HAvjL.gifv", "https://i.imgur.com/b8HAvjL.gifv",
"https://i.imgur.com/PIIfL15.gifv"] "https://i.imgur.com/PIIfL15.gifv"]
)) ))
elif random.random() < var.FORTUNE_CHANCE:
try:
out = subprocess.check_output(("fortune", "-s"))
except OSError as e:
if e.errno != 2:
# No such file or directory (fortune is not installed)
raise
else:
out = out.decode("utf-8", "replace")
out = out.replace("\n", " ")
# Replace tabs and multiple spaces with a single space.
out = re.sub(r"\s+", " ", out)
message.append(out)
if victim in var.HVISITED.values() and victim in bywolves: # victim was visited by some harlot and victim was attacked by wolves if victim in var.HVISITED.values() and victim in bywolves: # victim was visited by some harlot and victim was attacked by wolves
for hlt in var.HVISITED.keys(): for hlt in var.HVISITED.keys():

View File

@ -240,6 +240,7 @@ QUIT_MESSAGES_NO_REVEAL = ("\u0002{0}\u0002 suddenly falls over dead before the
"\u0002{0}\u0002 suddenly bursts into flames and is now all but a memory.") "\u0002{0}\u0002 suddenly bursts into flames and is now all but a memory.")
GIF_CHANCE = 1/50 GIF_CHANCE = 1/50
FORTUNE_CHANCE = 1/25
import botconfig import botconfig
import fnmatch import fnmatch