Make idlerpg daemon compatible to new annna interface. - annna - Annna the nice friendly bot.
(HTM) git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
---
(DIR) commit 9ac9a626966ebe392af14998d3ed750aad7e8f6a
(DIR) parent 972167062f331f659119e14b978c2fb493ef0083
(HTM) Author: Annna Robert-Houdin <annna@bitreich.org>
Date: Sun, 19 Oct 2025 14:34:58 +0200
Make idlerpg daemon compatible to new annna interface.
Diffstat:
M annna-channel-service | 2 +-
M modules/idlerpg/idlerpg-channel-se… | 27 +++++++++++++--------------
2 files changed, 14 insertions(+), 15 deletions(-)
---
(DIR) diff --git a/annna-channel-service b/annna-channel-service
@@ -6,7 +6,7 @@ case "${IRC_SERVER}" in
\#bitreich-idle)
export SERVICE_BASE="${ANNNA_MODBASE}/idlerpg"
# TODO: Fix idle service for new architecture.
- # ${SERVICE_BASE}/idlerpg-channel-service.py &
+ ${SERVICE_BASE}/idlerpg-channel-service.py &
exit
;;
\#bitreich-radio)
(DIR) diff --git a/modules/idlerpg/idlerpg-channel-service.py b/modules/idlerpg/idlerpg-channel-service.py
@@ -16,6 +16,11 @@ import errno
import fcntl
import functools
+def annna_alive(base):
+ if os.path.exists("%s/running" % (base)):
+ return 1
+ return 0
+
def readin_file(f):
lines = []
try:
@@ -60,7 +65,7 @@ def say(fpath, text):
def usage(app):
app = os.path.basename(app)
- print("usage: %s [-h] ircuser basepath ircpath server channel" % (app), file=sys.stderr)
+ print("usage: %s [-h]" % (app), file=sys.stderr)
sys.exit(1)
def main(args):
@@ -76,18 +81,14 @@ def main(args):
else:
assert False, "unhandled option"
- if len(largs) < 5:
- usage(args[0])
- return 1
-
- ircuser = largs[0]
- basepath = largs[1]
- ircpath = largs[2]
- server = largs[3]
- channel = largs[4]
+ annnabase = os.environ["ANNNA_BASE"]
+ ircuser = os.environ["IRC_USER"]
+ basepath = os.environ["SERVICE_BASE"]
+ ircpath = os.environ["ANNNA_IRCBASE"]
+ server = os.environ["IRC_SERVER"]
+ channel = os.environ["IRC_CHANNEL"]
serverpath = "%s/%s" % (ircpath, server)
chanpath = "%s/%s" % (serverpath, channel)
-
chaninpath = "%s/in" % (chanpath)
def get_channel_users():
@@ -109,14 +110,12 @@ def main(args):
return 1
penalties = readin_dictfile("%s/penalties.txt" % (basepath))
-
classes = readin_dictfile("%s/classes.txt" % (basepath))
hardware = readin_dictfile("%s/hardware.txt" % (basepath))
shields = readin_dictfile("%s/shields.txt" % (basepath))
weapons = readin_dictfile("%s/weapons.txt" % (basepath))
quests = readin_dictfile("%s/quests.txt" % (basepath))
events = readin_dictfile("%s/events.txt" % (basepath))
-
hackers = readin_dictfile("%s/hackers.txt" % (basepath))
for hacker in hackers.keys():
hackers[hacker][0] = int(hackers[hacker][0])
@@ -291,7 +290,7 @@ def main(args):
sys.exit(1)
chanoutfd.readlines()
- while 1:
+ while annna_alive(annnabase):
# Game ticks every 5 seconds.
try:
(rfds, wfds, sfds) = select.select([inotifyfd], [], [], 5)