mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-25 12:31:07 -05:00
Delete TextAdventures directory
Unsupported, bad ideas....
This commit is contained in:
parent
c1bf3092ac
commit
84672f3b41
@ -1,36 +0,0 @@
|
||||
Play interactive fiction Z-Machine games like the Infocom classic Zork.
|
||||
|
||||
Requires limnoria, python 3, pexpect
|
||||
|
||||
Uses the dfrotz (dumb frotz) interpreter https://github.com/DavidGriffith/frotz
|
||||
|
||||
git clone https://github.com/DavidGriffith/frotz<br>
|
||||
cd frotz<br>
|
||||
make dumb<br>
|
||||
sudo make install_dumb<br>
|
||||
|
||||
config plugins.frotz.dfrotzPath (path_to_dfrotz_binary) (default /usr/local/bin/dfrotz)
|
||||
Looks for games in ./games/ directory
|
||||
|
||||
usage:
|
||||
|
||||
adventure <game name> ex. adventure zork1.z5 - starts game
|
||||
|
||||
Game will process channel messages as commands while a game is running.
|
||||
|
||||
z <command> ex. z open mailbox, z look - send command manually
|
||||
|
||||
z <no input> - sends a blank line equivalent to [RETURN]/[ENTER] when needed
|
||||
|
||||
end - ends the game
|
||||
|
||||
games - lists contents of ./games/ directory
|
||||
|
||||
one game allowed to run per channel/pm. will prompt you to stop running games before allowing a new one to be started.
|
||||
this limits the number of potential child dfrotz processes and keeps this simpler in terms of routing the right game data
|
||||
to the right place.
|
||||
|
||||
python3 -m pip install pexpect
|
||||
|
||||
Games included here are easily found and freely available all over the net, their owners are their respective owners
|
||||
and if you believe a game should not be here contact me and I will remove it immediately.
|
@ -1,65 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2020, oddluck <oddluck@riseup.net>
|
||||
# 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.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# 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 OWNER 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.
|
||||
###
|
||||
|
||||
"""
|
||||
TextAdventures: Play interactive fiction (z-machine) games
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you're keeping the plugin in CVS or some similar system.
|
||||
__version__ = "2020.02.24+git"
|
||||
|
||||
# XXX Replace this with an appropriate author or supybot.Author instance.
|
||||
__author__ = supybot.Author("oddluck", "oddluck", "oddluck@riseup.net")
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
# This is a url where the most recent plugin package can be downloaded.
|
||||
__url__ = "https://github.com/oddluck/limnoria-plugins/"
|
||||
|
||||
from . import config
|
||||
from . import plugin
|
||||
from importlib import reload
|
||||
|
||||
# In case we're being reloaded.
|
||||
reload(config)
|
||||
reload(plugin)
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
|
||||
if world.testing:
|
||||
from . import test
|
||||
|
||||
Class = plugin.Class
|
||||
TextAdventures = config.TextAdventures
|
@ -1,81 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2020, oddluck <oddluck@riseup.net>
|
||||
# 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.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# 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 OWNER 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.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
|
||||
_ = PluginInternationalization("TextAdventures")
|
||||
except:
|
||||
# Placeholder that allows to run the plugin on a bot
|
||||
# without the i18n module
|
||||
_ = lambda x: x
|
||||
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified themself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
|
||||
conf.registerPlugin("TextAdventures", True)
|
||||
|
||||
|
||||
TextAdventures = conf.registerPlugin("TextAdventures")
|
||||
|
||||
conf.registerGlobalValue(
|
||||
TextAdventures,
|
||||
"dfrotzPath",
|
||||
registry.String(
|
||||
"/usr/local/bin/dfrotz", _("""The path to the dfrotz executable.""")
|
||||
),
|
||||
)
|
||||
|
||||
conf.registerGlobalValue(
|
||||
TextAdventures,
|
||||
"allowPrivate",
|
||||
registry.Boolean("True", _("""Allow games to be played over private message.""")),
|
||||
)
|
||||
|
||||
conf.registerChannelValue(
|
||||
TextAdventures,
|
||||
"requireCommand",
|
||||
registry.Boolean(
|
||||
"False",
|
||||
_(
|
||||
"""Require game input to be sent via command. Disables
|
||||
monitoring of chanel messages for game input."""
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
TextAdventures = conf.registerPlugin("TextAdventures")
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,182 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2020, oddluck <oddluck@riseup.net>
|
||||
# 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.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# 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 OWNER 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.
|
||||
###
|
||||
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.plugins as plugins
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.callbacks as callbacks
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import os
|
||||
import pexpect
|
||||
import re
|
||||
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
|
||||
_ = PluginInternationalization("TextAdventures")
|
||||
except ImportError:
|
||||
# Placeholder that allows to run the plugin on a bot
|
||||
# without the i18n module
|
||||
_ = lambda x: x
|
||||
|
||||
|
||||
class TextAdventures(callbacks.Plugin):
|
||||
"""
|
||||
Play Text Adventure Games (Infocom, Interactive Fiction, Z-Machine) .
|
||||
"""
|
||||
|
||||
threaded = True
|
||||
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(TextAdventures, self)
|
||||
self.__parent.__init__(irc)
|
||||
self.game = {}
|
||||
self.game_path = "{0}/games/".format(os.path.dirname(os.path.abspath(__file__)))
|
||||
self.binary = self.registryValue("dFrotzPath")
|
||||
|
||||
def adventure(self, irc, msg, args, input):
|
||||
"""<game_name>
|
||||
Open <game_name.z*>.
|
||||
"""
|
||||
channel = msg.args[0]
|
||||
if not self.registryValue("allowPrivate") and not irc.isChannel(channel):
|
||||
irc.reply("Sorry, this game must be played in channel")
|
||||
return
|
||||
elif self.registryValue("allowPrivate") and not irc.isChannel(channel):
|
||||
channel = msg.nick
|
||||
game_name = input
|
||||
self.game.setdefault(channel, None)
|
||||
if self.game[channel]:
|
||||
irc.reply(
|
||||
"There is a game already in progress on {0}. Please stop that game"
|
||||
" first.".format(channel)
|
||||
)
|
||||
else:
|
||||
irc.reply("Starting {0} on {1}. Please wait...".format(game_name, channel))
|
||||
game_file = "{0}{1}".format(self.game_path, game_name)
|
||||
self.game[channel] = pexpect.spawn(
|
||||
"{0} -m -S 0 {1}".format(self.binary, game_file)
|
||||
)
|
||||
response = self.output(self.game[channel])
|
||||
for line in response:
|
||||
if line.strip() and line.strip() != ".":
|
||||
irc.reply(line, prefixNick=False)
|
||||
|
||||
adventure = wrap(adventure, ["text"])
|
||||
|
||||
def output(self, output):
|
||||
response = []
|
||||
prompts = ["\n> >", "\n>", "\n\)", pexpect.TIMEOUT]
|
||||
output.expect(prompts, timeout=1)
|
||||
response = output.before
|
||||
response = response.decode().splitlines()
|
||||
return response
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
channel = msg.args[0]
|
||||
if irc.isChannel(channel) and callbacks.addressed(irc.nick, msg):
|
||||
return
|
||||
if not irc.isChannel(channel):
|
||||
channel = msg.nick
|
||||
if not self.registryValue("requireCommand") or not irc.isChannel(msg.args[0]):
|
||||
self.game.setdefault(channel, None)
|
||||
if self.game[channel]:
|
||||
try:
|
||||
command = msg.args[1]
|
||||
self.game[channel].sendline(r"{}".format(command))
|
||||
response = self.output(self.game[channel])
|
||||
for line in response[1:]:
|
||||
if line.strip() and line.strip() != ".":
|
||||
irc.reply(line, prefixNick=False)
|
||||
except:
|
||||
return
|
||||
else:
|
||||
return
|
||||
else:
|
||||
return
|
||||
|
||||
def end(self, irc, msg, args):
|
||||
"""
|
||||
End text adventure game.
|
||||
"""
|
||||
channel = msg.args[0]
|
||||
if not irc.isChannel(channel):
|
||||
channel = msg.nick
|
||||
self.game.setdefault(channel, None)
|
||||
if self.game[channel]:
|
||||
irc.reply("Stopping Game. Thanks for playing.")
|
||||
else:
|
||||
irc.reply("No game running in {0}".format(channel))
|
||||
try:
|
||||
self.game[channel].terminate(force=True)
|
||||
del self.game[channel]
|
||||
except:
|
||||
try:
|
||||
del self.game[channel]
|
||||
except:
|
||||
return
|
||||
return
|
||||
|
||||
end = wrap(end)
|
||||
|
||||
def z(self, irc, msg, args, command):
|
||||
"""[<input>]
|
||||
Send user input or blank line (ENTER/RETURN) to the game.
|
||||
"""
|
||||
channel = msg.args[0]
|
||||
if not irc.isChannel(channel):
|
||||
channel = msg.nick
|
||||
self.game.setdefault(channel, None)
|
||||
if self.game[channel]:
|
||||
if command:
|
||||
command = re.sub(r"^.?z", r"", r"{}".format(msg.args[1])).strip()
|
||||
self.game[channel].sendline(r"{}".format(command))
|
||||
else:
|
||||
self.game[channel].sendline()
|
||||
response = self.output(self.game[channel])
|
||||
for line in response[1:]:
|
||||
if line.strip() and line.strip() != ".":
|
||||
irc.reply(line, prefixNick=False)
|
||||
else:
|
||||
irc.reply("No game running in {0}?".format(channel))
|
||||
|
||||
z = wrap(z, [optional("text")])
|
||||
|
||||
def games(self, irc, msg, args):
|
||||
"""
|
||||
List files in the game directory.
|
||||
"""
|
||||
reply = ", ".join(sorted(os.listdir(self.game_path)))
|
||||
irc.reply(reply, prefixNick=False)
|
||||
|
||||
games = wrap(games)
|
||||
|
||||
|
||||
Class = TextAdventures
|
@ -1 +0,0 @@
|
||||
pexpect
|
@ -1,8 +0,0 @@
|
||||
from supybot.setup import plugin_setup
|
||||
|
||||
plugin_setup(
|
||||
'TextAdventures',
|
||||
install_requires=[
|
||||
'pexpect',
|
||||
],
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user