diff --git a/README.md b/README.md index 8f2a6c9e..cbfa4fe2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ 伝書フクロウという意味です。 ## About Carrier Owl + 前日のarxivから気になる論文にスコアを付けてslackに通知するシステムです。 @@ -42,21 +43,16 @@ - -3. **webhook urlの取得** - - 特定のslackチャンネルに流すための準備を行います。 - - incomming webhookの**webhook url**を取得してください。 - - 参考サイト - - [公式](https://slack.com/intl/ja-jp/help/articles/115005265063-Slack-での-Incoming-Webhook-の利用) - - [紹介記事](https://qiita.com/vmmhypervisor/items/18c99624a84df8b31008) - - slack通知の時のアイコンが設定できますので、よければこれ使ってください。 - - [icon](https://github.com/fkubota/Carrier-Owl/blob/master/data/images/carrier-owl.png) - +3. **通知先の設定** + 通知したいアプリケーションに応じて設定を行います。いくつでも設定可能です。 + + - Slackに通知する場合は[こちら](./docs/slack_setup.md) + - LINEに通知する場合は[こちら](./docs/line_setup.md) 4. **webhook urlの設定** - - step3で取得した `webhook url` を設定します。 + - step3で取得した `webhook url`(または `line token`) を設定します。 - 手順 a. `settings` をクリック。 @@ -67,29 +63,45 @@ c. `New repository secret` をクリック。 - d. Nameを `SLACK_ID` と入力。Valueを **step2** で取得した`webhook url`を貼り付けます。 + d. Nameを `SLACK_ID`(または `LINE_TOKEN` ) と入力。Valueを **step2** で取得した`webhook url`(また `line token`)を貼り付けます。 e. 最後に`Add secret`をクリックして登録完了です。 5. **領域の設定** + - 通知させたいarxivの論文の領域を指定します。 - **(computer scienceの人はこの手順を飛ばしてstep8に進んでも構いません)** - - `computer science` なら `cs` などそれぞれに名前がついています。以下の手順で確認します。 - 手順 - 1. [arxiv.org](https://arxiv.org)にアクセス - 2. 通知させたい領域の**resent**と書かれた部分をクリック。 - - - - 3. 遷移後のページのurlを見て、`list/`と`/recent`に囲われている文字列を使います。 - - - computer scienceの例: `https://arxiv.org/list/cs/recent` - - この場合、`cs` をこの後利用する。 - - 4. `config.yaml` 内の、`subject` を3で取得した文字列に変更します。(デフォルトでは`cs`になっています。) - + 1. 以下の表から通知を受け取りたいsubjectを選択して、urlをクリックしてください。 + + | subject | category | url | + | ------------------------------------------ | -------- | ----------------------------------------- | + | Astrophysics | astro-ph | [url](https://arxiv.org/archive/astro-ph) | + | Condensed Matter | cond-mat | [url](https://arxiv.org/archive/cond-mat) | + | Physics | physics | [url](https://arxiv.org/archive/physics) | + | Mathematics | math | [url](https://arxiv.org/archive/math) | + | Nonlinear Sciences | nlin | [url](https://arxiv.org/archive/nlin) | + | Computer Science | cs | [url](https://arxiv.org/archive/cs) | + | Quantitative Biology | q-bio | [url](https://arxiv.org/archive/q-bio) | + | Quantitative Finance | q-fin | [url](https://arxiv.org/archive/q-fin) | + | Statistics | stat | [url](https://arxiv.org/archive/stat) | + | Electrical Engineering and Systems Science | eess | [url](https://arxiv.org/archive/eess) | + | Economics | econ | [url](https://arxiv.org/archive/econ) | + + 2. さらに細かい分類を確認します + - 以下の例は、subject = `cs` をクリックした場合です。`cs.AI` や `cs.CL` などが細かな分類になります。 + + + + 3. `config.yaml` 内の、`subject` を2で確認した文字列に変更します。 + - デフォルトでは`cat:cs.*`になっています。これは、cs以下の小分類すべてを通知するという設定になります。 + - **複数領域指定** + - 複数領域指定も可能です。以下のよう `OR` でつなぎます。 + - ex1) `cat:cs.AI OR cat:cs.CV` + - ex2) `cat:physics.* OR cat:cs.*` + - ex3) `cat:physics.space-ph OR cat:cs.AI OR cat:q-bio.BM` 6. **キーワードの設定** @@ -119,11 +131,20 @@ - ここまでの変更がmasterブランチに反映されていれば、これですべての設定が完了したことになります。次の通知タイミングでslackに通知されます。 9. **test** - - 試しに動かしてみたい場合は、`master` ブランチから `test-send-to-slack` ブランチを作成してください。`test-send-to-slack` ブランチが作られるとgithub actionsが走って問題なければ通知されるはずです。 - - Actionsタブで様子を確認できます。 + - github actions の `workflow_dispatch` を使って通知タイミングを待たずにいつでも実行することができます。 + - Actionsタブでから、`Run workflow` をクリックすることでいつでも実行可能です。 + + - +## その他の設定 +- **score threshold** + 通知するスコアに閾値を設定することができます。`score >= scrore_threshold` を満たす論文のみ通知させることができま + す。 `config.yaml` 内の、`score_threshold` で設定できます(デフォルトは0になっています)。 ## Thanks -- [hppさん](https://github.com/hppRC)のお力をお借りして、v2.0.0から `github` だけで動作するようになりました。ご協力ありがとうございました。 +- [hppさん](https://github.com/hppRC)のPRにより、github actionsを使うことにより `github` だけで動作するようになりました。 + +- [wakamezakeさん](https://github.com/wakamezake)のPRにより、arxiv-apiを導入しました。 + +- [amagaeruさん](https://github.com/amagaeru1113)のPRにより、LINE通知機能を実装しました。 \ No newline at end of file diff --git a/config.yaml b/config.yaml index 89308bd5..4b509c40 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,5 @@ # arxivの学問領域の指定 -subject: 'cs.*' +subject: 'cat:cs.*' # 検索キーワード keywords: diff --git a/data/carrier-owl.gvdesign b/data/carrier-owl.gvdesign index 6dd785d8..4a4a5365 100644 Binary files a/data/carrier-owl.gvdesign and b/data/carrier-owl.gvdesign differ diff --git a/data/images/10.png b/data/images/10.png new file mode 100644 index 00000000..e05a8a92 Binary files /dev/null and b/data/images/10.png differ diff --git a/data/images/11.png b/data/images/11.png new file mode 100644 index 00000000..7cc45f04 Binary files /dev/null and b/data/images/11.png differ diff --git a/data/images/line/001.png b/data/images/line/001.png new file mode 100644 index 00000000..de666f84 Binary files /dev/null and b/data/images/line/001.png differ diff --git a/data/images/line/002.jpg b/data/images/line/002.jpg new file mode 100644 index 00000000..c46ec3f7 Binary files /dev/null and b/data/images/line/002.jpg differ diff --git a/data/images/system.png b/data/images/system.png index 85504abf..dcb41286 100644 Binary files a/data/images/system.png and b/data/images/system.png differ diff --git a/docs/line_setup.md b/docs/line_setup.md new file mode 100644 index 00000000..06569607 --- /dev/null +++ b/docs/line_setup.md @@ -0,0 +1,14 @@ +**LINE通知導入手順** + +1. LINE Notify(https://notify-bot.line.me/ja/) にアクセスし、ログイン + +2. ページ右上にある自分の名前をクリックし、マイページに移動 + +3. マイページ下部でアクセストークン発行 + + - 下記ページで発行 + + + + - 発行時、通知するトークルームを設定できるので同じトークルームに入っている複数名に通知可能 + diff --git a/docs/slack_setup.md b/docs/slack_setup.md new file mode 100644 index 00000000..18e9daf0 --- /dev/null +++ b/docs/slack_setup.md @@ -0,0 +1,15 @@ +**webhook urlの取得** + +特定のslackチャンネルに流すための準備を行います。 + +1. incomming webhookの**webhook url**を取得してください。 + - 参考サイト + - [公式](https://slack.com/intl/ja-jp/help/articles/115005265063-Slack-での-Incoming-Webhook-の利用) + + - [紹介記事](https://qiita.com/vmmhypervisor/items/18c99624a84df8b31008) + +2. slack通知の時のアイコンが設定できますので、よければこれ使ってください。 + - [icon](https://github.com/fkubota/Carrier-Owl/blob/master/data/images/carrier-owl.png) + + + diff --git a/src/carrier_owl.py b/src/carrier_owl.py index 0c59861e..1f1552b8 100644 --- a/src/carrier_owl.py +++ b/src/carrier_owl.py @@ -91,15 +91,14 @@ def notify(results: list, slack_id: str, line_token: str) -> None: word = result.words score = result.score - text = f''' - \n score: `{score}` - \n hit keywords: `{word}` - \n url: {url} - \n title: {title} - \n abstract: - \n \t {abstract} - \n {star} - ''' + text = f'\n score: `{score}`'\ + f'\n hit keywords: `{word}`'\ + f'\n url: {url}'\ + f'\n title: {title}'\ + f'\n abstract:'\ + f'\n \t {abstract}'\ + f'\n {star}' + send2app(text, slack_id, line_token) @@ -171,7 +170,7 @@ def main(): yesterday = datetime.datetime.today() - datetime.timedelta(days=1) yesterday_str = yesterday.strftime('%Y%m%d') # datetime format YYYYMMDDHHMMSS - arxiv_query = f'{subject} AND ' \ + arxiv_query = f'({subject}) AND ' \ f'submittedDate:' \ f'[{yesterday_str}000000 TO {yesterday_str}235959]' articles = arxiv.query(query=arxiv_query,