Skip to content

Instantly share code, notes, and snippets.

@vchrombie
Created April 27, 2020 18:39
Show Gist options
  • Save vchrombie/bfd6d967e03bbe28cf4241995fb4b91b to your computer and use it in GitHub Desktop.
Save vchrombie/bfd6d967e03bbe28cf4241995fb4b91b to your computer and use it in GitHub Desktop.
zulip backend
/home/p0tt3r/chaoss/sources/VENV_DIR/bin/python /home/p0tt3r/chaoss/zulip/python-zulip-api/zulip/zulip/script.py
{'anchor': 0,
'found_anchor': False,
'found_newest': False,
'found_oldest': True,
'history_limited': False,
'messages': [{'avatar_url': 'https://zulip-avatars.s3.amazonaws.com/1000/1cd87892343b6620726b112851f0b66cbda4a68f?x=x&version=4',
'client': 'Internal',
'content': 'Welcome to #**importlib**.',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159280404,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'welcome-bot@zulip.com',
'sender_full_name': 'Welcome Bot',
'sender_id': 100007,
'sender_realm_str': 'zulipcore',
'sender_short_name': 'welcome-bot',
'stream_id': 187177,
'subject': 'hello',
'submessages': [],
'timestamp': 1551022959,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/163acaf31cfd01645493404a2d379df6?d=identicon&version=1',
'client': 'ZulipElectron',
'content': '@**Steven Ma** Try this in a `Dockerfile`:\n'
'```\n'
'FROM ubuntu:bionic\n'
'\n'
'RUN apt update\n'
'RUN apt upgrade -y\n'
'RUN apt install -y python3 python3-dev python3-venv '
'python3-pip\n'
'RUN python3 -m pip install -U pip tox pip-run\n'
'```',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159281179,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'jaraco@jaraco.com',
'sender_full_name': 'Jason R. Coombs',
'sender_id': 113001,
'sender_realm_str': 'python',
'sender_short_name': 'jaraco',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551024348,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/163acaf31cfd01645493404a2d379df6?d=identicon&version=1',
'client': 'ZulipElectron',
'content': 'Build with `docker build . -t py3tox` Then run with '
'`docker run -it py3tox -v ...`',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159281235,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'jaraco@jaraco.com',
'sender_full_name': 'Jason R. Coombs',
'sender_id': 113001,
'sender_realm_str': 'python',
'sender_short_name': 'jaraco',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551024420,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/163acaf31cfd01645493404a2d379df6?d=identicon&version=1',
'client': 'ZulipElectron',
'content': "Or even better, don't bother with that Dockerfile.",
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159281899,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'jaraco@jaraco.com',
'sender_full_name': 'Jason R. Coombs',
'sender_id': 113001,
'sender_realm_str': 'python',
'sender_short_name': 'jaraco',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551025646,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/163acaf31cfd01645493404a2d379df6?d=identicon&version=1',
'client': 'ZulipElectron',
'content': 'Instead run `docker run -it -v ... '
'jaraco/py37-tox`.',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'edit_history': [{'prev_content': 'Instead run `docker run -it '
'jaraco/py37-tox -v ...`.',
'prev_rendered_content': '<p>Instead run '
'<code>docker run '
'-it jaraco/py37-tox '
'-v ...</code>.</p>',
'prev_rendered_content_version': 1,
'timestamp': 1551025941,
'user_id': 113001}],
'flags': ['read', 'historical'],
'id': 159281902,
'is_me_message': False,
'last_edit_timestamp': 1551025941,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'jaraco@jaraco.com',
'sender_full_name': 'Jason R. Coombs',
'sender_id': 113001,
'sender_realm_str': 'python',
'sender_short_name': 'jaraco',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551025661,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/0920d21ea0a718d5106c45ae10cecf01?d=identicon&version=1',
'client': 'ZulipElectron',
'content': 'Hey Jason,\n'
"If you think you'll be coming back decently soon "
'let me know. If not, I might just leave and then we '
'can continue to contact each other through this '
'thread.',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159284211,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'stevenjma@gmail.com',
'sender_full_name': 'Steven Ma',
'sender_id': 209389,
'sender_realm_str': 'python',
'sender_short_name': 'stevenjma',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551029804,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/163acaf31cfd01645493404a2d379df6?d=identicon&version=1',
'client': 'ZulipElectron',
'content': '```\n'
'{\n'
'\tstr(self.site_dir / "distinfo_pkg...dist-info": '
'{\n'
'\t\t"METADATA": self.metadata,\n'
'\t\t"RECORD": "mod.py\\n",\n'
'\t\t\n'
'\t},\n'
'\t"mod.py": """\n'
'\t\tdef main():\n'
'\t\t\tprint("hello world")\n'
'\t\t""",\n'
'}\n'
'```',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159289082,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'jaraco@jaraco.com',
'sender_full_name': 'Jason R. Coombs',
'sender_id': 113001,
'sender_realm_str': 'python',
'sender_short_name': 'jaraco',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551038048,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/0920d21ea0a718d5106c45ae10cecf01?d=identicon&version=1',
'client': 'ZulipElectron',
'content': '[pasted '
'image](/user_uploads/3607/XRldRB3uISNBAF--cSFq75k1/pasted_image.png) \n'
"Well, codecov doesn't like me it seems. Feel free "
'to give instruction here in terms of the sort of '
"CPython work you'd like me to do.",
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159300050,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'stevenjma@gmail.com',
'sender_full_name': 'Steven Ma',
'sender_id': 209389,
'sender_realm_str': 'python',
'sender_short_name': 'stevenjma',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551047725,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/163acaf31cfd01645493404a2d379df6?d=identicon&version=1',
'client': 'ZulipElectron',
'content': '@**Steven Ma** That error happens to every '
'contributor, unfortunately. I should file a ticket '
'about it. Your work was fine.',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159310770,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'jaraco@jaraco.com',
'sender_full_name': 'Jason R. Coombs',
'sender_id': 113001,
'sender_realm_str': 'python',
'sender_short_name': 'jaraco',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551066955,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/0920d21ea0a718d5106c45ae10cecf01?d=identicon&version=1',
'client': 'ZulipElectron',
'content': "Awesome, glad to know my code wasn't faulty. I saw "
"your message on the repo for issue 47; I'll "
"probably get to it in a couple days as I'm pretty "
'drained right now.',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159310824,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'stevenjma@gmail.com',
'sender_full_name': 'Steven Ma',
'sender_id': 209389,
'sender_realm_str': 'python',
'sender_short_name': 'stevenjma',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551067006,
'topic_links': [],
'type': 'stream'}],
'msg': '',
'result': 'success'}
Process finished with exit code 0
/home/p0tt3r/chaoss/sources/VENV_DIR/bin/python /home/p0tt3r/chaoss/zulip/python-zulip-api/zulip/zulip/script.py
{'anchor': 159310824,
'found_anchor': True,
'found_newest': True,
'found_oldest': False,
'history_limited': False,
'messages': [{'avatar_url': 'https://secure.gravatar.com/avatar/0920d21ea0a718d5106c45ae10cecf01?d=identicon&version=1',
'client': 'ZulipElectron',
'content': "Awesome, glad to know my code wasn't faulty. I saw "
"your message on the repo for issue 47; I'll "
"probably get to it in a couple days as I'm pretty "
'drained right now.',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 159310824,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'stevenjma@gmail.com',
'sender_full_name': 'Steven Ma',
'sender_id': 209389,
'sender_realm_str': 'python',
'sender_short_name': 'stevenjma',
'stream_id': 187177,
'subject': 'Testing on Linux in docker',
'submessages': [],
'timestamp': 1551067006,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/163acaf31cfd01645493404a2d379df6?d=identicon&version=1',
'client': 'ZulipMobile',
'content': 'Hi @**Barry Warsaw** . If you have some time today, '
'would you review the MRs in importlib_metadata? '
'There are four. I’m planning to merge those '
'tomorrow (including port to CPython).',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 175270341,
'is_me_message': False,
'reactions': [],
'recipient_id': 303900,
'sender_email': 'jaraco@jaraco.com',
'sender_full_name': 'Jason R. Coombs',
'sender_id': 113001,
'sender_realm_str': 'python',
'sender_short_name': 'jaraco',
'stream_id': 187177,
'subject': 'Core sprint refresh',
'submessages': [],
'timestamp': 1568054275,
'topic_links': [],
'type': 'stream'},
{'avatar_url': 'https://secure.gravatar.com/avatar/01aa7d6d4db83982a2f6dd363d0ee0f3?d=identicon&version=1',
'client': 'ZulipElectron',
'content': '```quote\n'
'Hi @**Barry Warsaw** . If you have some time today, '
'would you review the MRs in importlib_metadata? '
'There are four. I’m planning to merge those '
'tomorrow (including port to CPython).\n'
'```\n'
'Done! Some I straight up approved, and others I '
'had some comments.',
'content_type': 'text/x-markdown',
'display_recipient': 'importlib',
'flags': ['read', 'historical'],
'id': 175296917,
'is_me_message': False,
'reactions': [{'emoji_code': '2764',
'emoji_name': 'heart',
'reaction_type': 'unicode_emoji',
'user': {'email': 'jaraco@jaraco.com',
'full_name': 'Jason R. Coombs',
'id': 113001}}],
'recipient_id': 303900,
'sender_email': 'barry@python.org',
'sender_full_name': 'Barry Warsaw',
'sender_id': 112547,
'sender_realm_str': 'python',
'sender_short_name': 'barry',
'stream_id': 187177,
'subject': 'Core sprint refresh',
'submessages': [],
'timestamp': 1568076835,
'topic_links': [],
'type': 'stream'}],
'msg': '',
'result': 'success'}
Process finished with exit code 0
import requests
import json
from pprint import pprint
BOT_EMAIL = "perceval-bot@zulipchat.com"
API_KEY = "xxxx"
URL = "https://python.zulipchat.com/"
STREAM = "importlib"
request = {
'anchor': 'oldest', # we can use the message `id` here
'num_before': '0',
'num_after': '10',
'apply_markdown': 'false',
'narrow': json.dumps([{'operator': 'stream', 'operand': '{}'.format(STREAM)}])
}
kwargs = {'params': request}
session = requests.Session()
session.auth = requests.auth.HTTPBasicAuth(BOT_EMAIL, API_KEY)
res = session.request("GET",
"https://python.zulipchat.com/api/v1/messages",
**kwargs)
pprint(res.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment