cmdrmcdonald / EliteDangerousDataProvider

Apache License 2.0
133 stars 31 forks source link

Galnet news #175

Closed Tkael closed 7 years ago

Tkael commented 7 years ago

I have modified the script for Galnet news, but it is hard to test adequately with the current test function embedded in EDDI (I cannot test more than one variant of the input). I thought I'd pass along what I have and see if you can improve it:

Galnet news published {set statustitle to "^(Galactic News: ((Weekly .*)|(Starport Status Update)))|(Powerplay: Incoming Update)"}

{ I'm trying to make galnet articles persistent. Most of this code is intended to do that, but it doesn't work yet and still needs tweaking. }

{set ofinterestindex to []} {set ofinteresttitle to []} {set ofinterestcontent to []} {set notofinterestindex to []} {set notofinteresttitle to []} {set notofinterestcontent to []}

{set galnetcnt to len(event.items)} {set interestcnt to 0} {set notinterestcnt to 0}

{if galnetcnt = 1: {if !match(event.items[0].title, statustitle): {set ofinterestindex to cat(ofinterestindex, [0])} {set ofinteresttitle to cat(ofinteresttitle, [0])} {set ofinterestcontent to cat(ofinterestcontent, [0])} {set interestcnt to interestcnt + 1} |else: {set notofinterestindex to cat(notofinterestindex, [0])} {set notofinteresttitle to cat(notofinteresttitle, [0])} {set notofinterestcontent to cat(notofinterestcontent, [0])} {set notinterestcnt to notinterestcnt + 1} } |elif galnetcnt > 1: {set item to 0} {while item < galnetcnt: {if !match(event.items[item].title, statustitle): {set ofinterestindex to cat(ofinterestindex, [item])} {set ofinteresttitle to cat(ofinteresttitle, [item])} {set ofinterestcontent to cat(ofinterestcontent, [item])} {set interestcnt to interestcnt + 1} |else: {set notofinterestindex to cat(notofinterestindex, [item])} {set notofinteresttitle to cat(notofinteresttitle, [item])} {set notofinterestcontent to cat(notofinterestcontent, [item])} {set notinterestcnt to notinterestcnt + 1} } {set item to item + 1} } }

{F("Galnet news report")}

Galnet news report {if interestcnt = 0:

Gal-net news has been updated with
{galnetcnt} new article{if galnetcnt > 1: "s"}, but there is nothing notable to report.

|elif interestcnt = 1 && galnetcnt = 1:

A{OneOf(" noteworthy", "n interesting")} new Gal-net article has been published, entitled {event.items[0].title}.
It reads: {event.items[0].content}.

|elif interestcnt = 1 && galnetcnt > 1:

{galnetcnt} new Gal-net articles have been published, including one 
{OneOf("which may be of interest", "of potential interest", "of interest", "of note", "which may be noteworthy")}.
It is entitled {event.items[0].title} and reads: {event.items[0].content}.

|elif interestcnt > 1 && galnetcnt > 1:

{len(interestcnt)} new Gal-net articles
{OneOf("which may be of interest", "of potential interest", "of interest", "of note", "which may be noteworthy")}
have been 
{OneOf("published.", "received.", "downloaded.")}
{set item to 0}
{while item < len(interestcnt):
    {set item to ofinterestindex[item]}
    {if item = 0:
        The first is entitled {event.items[item].title}
        {if !match(event.items[item].title, statustitle):
            , and reads: {event.items[item].content}
        }.
    |elif item = 1:
        The second is entitled {event.items[item].title}
        {if !match(event.items[item].title, statustitle):
            , and reads: {event.items[item].content}
        }.
    |elif item = len(event.items) - 1:
        The last is entitled {event.items[item].title}
        {if !match(event.items[item].title, statustitle):
            , and reads: {event.items[item].content}
        }.
    |else:
        The next is entitled {event.items[item].title}
        {if !match(event.items[item].title, statustitle):
            , and reads: {event.items[item].content}
        }.
    }
    {set item to item + 1}
    {Pause(1000)}

}

}

cmdrmcdonald commented 7 years ago

Thank you for this script. The next release of EDDI will have persistence for Galnet articles; see https://github.com/cmdrmcdonald/EliteDangerousDataProvider/wiki/Galnet-Monitor for details.

Tkael commented 7 years ago

Sounds like you've progressed far beyond where I was. Looking forward to it. :-)