Skip to content

Commit

Permalink
limit, add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcasavant committed Feb 11, 2023
1 parent 17869c4 commit 03a6358
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# MaubotHeadlines

## Usage

Load plugin and set your NewsAPI.org API key in the config.

Then:

```
!findheadline Texas man dressed as clown nominates himself for Austin Energy CEO after week of outages: 'Most qualified'
```

will cause Maubot to reply to you with a link the most popular matching headline.
3 changes: 1 addition & 2 deletions headlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ def do_update(self, helper: ConfigUpdateHelper) -> None:
helper.copy("newsapi_api_key")

async def lookup(http, api_key, headline):
params = "&".join(f"{k}={v}" for k, v in {"q": headline, "sortBy": "popularity", "apiKey": api_key}.items())
params = "&".join(f"{k}={v}" for k, v in {"q": headline, "sortBy": "popularity", "apiKey": api_key, "pageSize": 1}.items())
url = f"https://newsapi.org/v2/everything?{params}"
print(url)

async with http.get(url) as response:
response = await response.json()
Expand Down

0 comments on commit 03a6358

Please sign in to comment.