diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-08-05 02:45:21 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-08-05 02:45:21 -0300 |
commit | 94e9adf8e8f4461ab2306c5ab3970bcc9d3d65da (patch) | |
tree | 12fd72cf2c07fa6a4d003d4ef66682d8698569a9 /game/irc.rpy | |
parent | 11cff74cb758c08c0baba15f6eb501dd640d1f02 (diff) | |
download | client-94e9adf8e8f4461ab2306c5ab3970bcc9d3d65da.tar.gz client-94e9adf8e8f4461ab2306c5ab3970bcc9d3d65da.tar.bz2 client-94e9adf8e8f4461ab2306c5ab3970bcc9d3d65da.tar.xz client-94e9adf8e8f4461ab2306c5ab3970bcc9d3d65da.zip |
Bring IRC Bot back to life. If anyone still cares with it, that is!
Diffstat (limited to 'game/irc.rpy')
-rw-r--r-- | game/irc.rpy | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/game/irc.rpy b/game/irc.rpy index 870bc1c..35e05e3 100644 --- a/game/irc.rpy +++ b/game/irc.rpy @@ -34,8 +34,8 @@ init python: sys.setdefaultencoding('utf8') irc_online=False - server = "irc.freenode.org" - irc_channel = "#tmw2-spheres" + server = "irc.libera.chat" + irc_channel = "#mana-spheres" # TODO: Replace this with some uuid4()? irc_nick = "GS_" + get_token()[:3] + str(random.randint(1, 10000)) irc_auth=IRC_AUTH_NONE @@ -45,28 +45,31 @@ init python: irc.connect((server, 6667)) return - def irc_receive(raw): + def irc_receive(raw, irc_sender=""): global irc_buffer - sender="IRC" + if irc_sender == "": + sender="IRC" - # Control buffer length - if (len(irc_buffer) >= MAX_IRC_BUFFER): - nil=irc_buffer.pop(0) - del nil + # Control buffer length + if (len(irc_buffer) >= MAX_IRC_BUFFER): + nil=irc_buffer.pop(0) + del nil - # Find sender if not supplied - try: - p1=raw.find('<')+1 - p2=raw.find('>') - if p2 <= p1: - raise Exception("Invalid sender") - sender=raw[p1:p2] - except: + # Find sender if not supplied try: - p1=raw.find("!") - sender="IRC."+raw[1:p1] + p1=raw.find('<')+1 + p2=raw.find('>') + if p2 <= p1: + raise Exception("Invalid sender") + sender=raw[p1:p2] except: - sender="IRC" + try: + p1=raw.find("!") + sender="IRC."+raw[1:p1] + except: + sender="IRC" + else: + sender = irc_sender # Extract message try: @@ -150,6 +153,13 @@ init python: stdout("[IRC] Erroneous Authentication on 376 message") irc_online=True + # Would be nice to show MOTD + if text.find("372 " + irc_nick) != -1: + for line in text.split("\n"): + if "372" in line: + print("[372] %s" % line) + irc_receive(line, "MOTD") + if irc_auth == IRC_AUTH_CHAN: # IRC Syntax # :nick!hostname PRIVMSG #tmw2-spheres :<nickname> msg @@ -181,10 +191,11 @@ screen pub(): frame: background Frame("gui/frame.png", 0, 0) xalign 0.5 - yalign 0.5 + yalign 1.0 ymargin 15 ypadding 10 xmargin 10 + ymaximum 0.8 # FIXME - Breaks the viewport vbox: spacing 30 textbutton _("Exit") action Return("") @@ -196,10 +207,12 @@ screen pub(): draggable True arrowkeys True xfill False + ymaximum 0.7 scrollbars "vertical" vbox: xalign 0.5 + ymaximum 0.7 spacing 5 label _("%s" % persistent.nickname) null height 40 @@ -223,7 +236,7 @@ screen pub(): else: label _("IRC Integration is not active.") # FIXME inform if IRC is disabled - # Ask user to comply with Freenode TOS etc. + # Ask user to comply with Libera Chat TOS etc. - timer 1.0 action Function(renpy.restart_interaction) repeat True + timer 0.5 action Function(renpy.restart_interaction) repeat True |