wwivbbs/wwiv

oneliners.bas not saving one liners on linux

Opened this issue · 9 comments

Using Linux Mint / Ubuntu. The provided oneliners.bas does not save one liners when added to the logon event within WWIV.INI. It is set up as @oneliners.bas within WWIV.ini and have scripts turned on in wwivconfig, while also have tried package file on, and package OS on (or set to YES). **Update also tested on Raspberry Pi Bookshelf / Buster / Debian and does not work their either. Could be outdated .bas, however I see it working on other 5.9 windows versions so thought I'd put it here.

Would like the ability to use basic text files for read/write using basic scripting if not already available for things such as creating one liner mods with obvious restrictions from displaying real name and passwords. If this exists, it would be helpful to see an example of a how to read/write to a text or even data file within Linux using WWIV basic scripting for reference and for other mod ideas.

Tied to this, someone requested the ability to save to a text file for purpose of having the script post to an FTN sub such as FSX_BOT or FSX_DAT, and I'd like to add the ability to post to a WWIVnet native base also, such as an experimental sub one can subscribe to. This would allow for interBBS one liners and or last callers for those of us whom may or may not have FTN's on our WWIV BBSes. Being able to code write lines to a text file, with user data such as alias, last call, gold earned, etc. can then be pushed to another BBS or used with a webhook to discord.

Being "new again" to WWIV, I'd like to see an example as to how one can create logon/logoff events to include multiple scripts, command line instructions for .sh or .bat files, multiple .bas scripts, extra ansi files being displayed, extra text written (clear screens and pauses,) all occurring within one logon process file. I would assume it's a .bas file however new to them.

wwiv commented

Thanks for the report - The oneliners.bas script uses "wwiv.data.save" to save the data, it'll be in a JSON file under the data/ directory. Allowing the script to write and then push to a message base is an intersting idea, I think there's an issue here already for the message api to be opened up (I started on it once, but kept hitting some issues making it harder than I expected).

As for why oneliners isn't saving, I'll have to check it out could be a permissions issue, look in data/ and subdirs for for new JSON files. Mine is a file called this:
ONELINERS.script.json

With the following content:

{
    "data": [
        {
            "type": 0,
            "s": "|15Liner? Innat what you put on your cupboard shelves?"
        },
        {
            "type": 0,
            "s": "|11Hey your one liner is working?!  Mine on linux won't save :("
        }
    ]
}

I see the same thing on debian running 5.9.0.3697

the file on mine is oneliners.script.json. maybe an uppercase issue has crept in when saving. It's reading it fine.

These are the only .json files within my /wwiv/data directory

-rwxrwxrwx 1 ghost ghost 2605 Jun 1 21:01 autoval.json
-rwxrwxrwx 1 ghost ghost 709 Jan 6 10:51 bbslist.json
-rwxrwxrwx 1 ghost ghost 1290 Jun 2 17:11 chains.json
-rwxrwxrwx 1 ghost ghost 631 Jan 20 05:59 conference.json
-rwxrwxrwx 1 ghost ghost 2156 Jan 20 05:57 dirs.json
-rwxrwxrwx 1 ghost ghost 613 Feb 24 08:21 gfiles.json
-rwxrwxrwx 1 ghost ghost 28613 Jul 2 2023 menu_commands.json
-rwxrwxrwx 1 ghost ghost 360 Feb 25 07:28 networks.json
-rwxrwxrwx 1 ghost ghost 72757 Jun 1 21:01 sl.json
-rwxrwxrwx 1 ghost ghost 10956 Feb 25 07:35 subs.json
-rw-r--r-- 1 ghost ghost 23 Feb 3 23:37 wwivd.autoblock.json
-rwxrwxrwx 1 ghost ghost 1582 Jun 1 21:01 wwivd.json

Error code I can see via local only, maybe this will help?
Error:
Line 95, Col 6 Code 27, Abort Code 6 Name/Handle....... SysOp #1
Message: Incomplete structuInternet Address.. None.
Last0IP-Address...XXXX.XXX.XXX.XXX
Failure exiting script: 'oneliners' error code

      However it does this over telnet and ssh as well, I just don't see this error so maybe unrelated as this is my "test machine" i'm using at the moment.
wwiv commented

which version of wwiv?

wwiv commented

I wonder if you are running into paladin-t/my_basic#59

My apologies for the delayed reply, I'm running wwiv 5.9.0 development. No .json file is saving at all using the included oneliners.bas example script.

This is the .bas code. I don't see any reference to it saving to .json rather to a GLOBAL data file: wwiv.data.save("GLOBAL", l)

'
' Reinterpretation of the classic OneLiners originally
' written by Σ└¡ (Eli).
'
' This version is written in WWIVbasic v5.3 as a sample
' application.
'
import "@wwiv.io"

'
' Prints the list to the screen, one row at a time.
'
def PrintList(l)
i = iterator(l)
While move_next(i)
Print get(i)
Wend
enddef

' Returns the WWIV Pipe Color Code for
' the color name displayed in onliners
def PipeColor(c)
If c = 1 then
return "|15"
ElseIf c = 2 then
return "|01"
ElseIf c = 3 then
return "|10"
ElseIf c = 4 then
return "|12"
ElseIf c = 5 then
return "|13"
ElseIf c = 6 then
return "|07"
ElseIf c = 7 then
return "|11"
ElseIf c = 8 then
return "|14"
ElseIf c = 9 then
return "|09"
endif
' Default color.
return "|07"
enddef

def EnterOneLiner()
outstr("|15 1:White|01 2:DkBlue|10 3:Green|12 4:Red|13 5:Purple|07 6:Gray|11 7:Cyan|14 8:Yellow|09 9:Blue")
nl()
outstr("What Color? ")

color = getkey()
nl()
colorcode = ASC(LEFT(color, 1)) - ASC("0")
pipecode = PipeColor(colorcode)
outstr("|10Enter Your One Liner:")
nl()
outstr("|#9: ")
s = gets(72)

wwiv.io.outstr("|10Anonymous? ")
an = wwiv.io.ny()
If an Then
name = "Anonymous"
Else
namepart = wwiv.interpret("N")
number = wwiv.interpret("#")
name = namepart + " #" + number
End If
Return pipecode + name + " - " + s
Enddef

def Main()
l = list()
wwiv.data.load("GLOBAL", l)
done = False
cls()
While True
wwiv.io.printfile("oneliner");
PrintList(l)
nl()
outstr("|#9Would you like to add an oneliner? ")

If Not yn() Then
Return
EndIf
s = EnterOneLiner()
If len(l) > 10 Then
Remove(l, 0)
EndIf
Push(l, s)
wwiv.data.save("GLOBAL", l)
wend
enddef

Main()

wwiv commented

That line to GLOBAL should be it.

Hmm, data/ONELINERS.script.json is the file and it seems to work for me.