huginn / huginn

Create agents that monitor and act on your behalf. Your agents are standing by!
MIT License
43.43k stars 3.77k forks source link

Rss and Trigger agents combine #2239

Open keremcankabadayi opened 6 years ago

keremcankabadayi commented 6 years ago

hey!

i have some rss events. i'm trying to use TriggerAgent

my TriggerAgent looks like:

{
  "expected_receive_period_in_days": "1",
  "keep_event": "true",
  "rules": [
    {
      "type": "regex",
      "value": ".*\\/Collateral\\/.*",
      "path": "$.title.*"
    }
  ],
  "message": "{{title}}"
}

and my event:

{
  "id": "https://www.planetdp.org/subtitle/collateral-sub253687",
  "url": "https://www.planetdp.org/subtitle/collateral-sub253687",
  "urls": [
    "https://www.planetdp.org/subtitle/collateral-sub253687"
  ],
  "links": [
    {
      "href": "https://www.planetdp.org/subtitle/collateral-sub253687",
      "rel": "alternate",
      "type": "text/html"
    }
  ],
  "title": "Collateral Sezon : 1,Bölüm : Paket Türkçe Altyazı",
  "description": "25 fps fps, SubRip",
  "content": "Collateral Türkçe Türkçe Altyazı",
  "image": null,
  "enclosure": null,
  "authors": [
    "Reşat Bir"
  ],
  "categories": [],
  "date_published": null,
  "last_updated": "2018-03-09T11:27:12+03:00"
}

my goal is captured a word from {{title}} or {{content}} in the event. and extra question is that how i'm gonna add another word in the regex value? like *\\/wordone | wordtwo\\/.*?

virtadpt commented 6 years ago

Do you mean "wordtwo in addition to wordone" or do you mean "wordone or wordtwo"? You can do both with Trigger Agent but it's easier to explain the one you need first to keep it from getting confusing.

keremcankabadayi commented 6 years ago

word1 or word2what i'm trying here. actually, i wanna know [word1 and word2 or word3 and word4]

virtadpt commented 6 years ago

Okay. With Trigger Agent, by default it will only fire if all of the configured rules match. For the former case, just put your regex rules in a single Trigger Agent in separate rules, and that'll do what you want. For the latter case I recommend two Trigger Agents in Parallel (word1 AND word2, word3 AND word4) with both feed into a Deduplication Agent so that you only get one copy of the event you want.

dsander commented 6 years ago

A simple OR can also be handled with must_match = 1, configure two rules for the words you are looking for and the Agent will trigger if either of the two rules matches. The AND has to be done in the two regular expressions though.

keremcankabadayi commented 6 years ago

so, i couldn't figure my configuration out. I tried some but it didn't work. how should it be?

dsander commented 6 years ago

What did you try and what did not work? 😄