Created
September 17, 2019 05:31
-
-
Save alx/d43dcdeab6951c6c86f158294c5492db to your computer and use it in GitHub Desktop.
Arxiv bot for rocketchat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arxiv | |
from requests import sessions | |
from pprint import pprint | |
from rocketchat_API.rocketchat import RocketChat | |
import arxiv | |
import re | |
regex = r"^https://arxiv\.org\/.*\/(\d+\.\d+(?:v1)?).*$" | |
login = "" | |
password = "" | |
group_id = "" | |
with sessions.Session() as session: | |
rocket = RocketChat(login, password, server_url='https://chat.jolibrain.com', session=session) | |
history = rocket.groups_history(group_id).json() | |
for message in history['messages']: | |
arxiv_match = re.match(regex, message['msg']) | |
if bool(arxiv_match): | |
id_list = [arxiv_match.group(1)] | |
result = arxiv.query(id_list=id_list, max_results=1, prune=True) | |
for paper in result: | |
pprint(paper['summary']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment