Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_recent_messages(client, narrow_str, count=100):
# type: (zulip.Client, str, int) -> List[Dict[str, Any]]
narrow = [word.split(':') for word in narrow_str.split()]
req = {
'narrow': narrow,
'num_before': count,
'num_after': 0,
'anchor': 1000000000,
'apply_markdown': False
}
old_messages = client.do_api_query(req, zulip.API_VERSTRING + 'messages', method='GET')
if 'messages' not in old_messages:
return []
return old_messages['messages']
import sys
import os
import simplejson
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'api'))
import zulip
zulip_client = zulip.Client(site="http://localhost:9991", client="ZulipGithubPayloadSender/0.1")
payload_dir = "zerver/fixtures/github"
for filename in os.listdir(payload_dir):
with open(os.path.join(payload_dir, filename)) as f:
req = simplejson.loads(f.read())
req['api-key'] = zulip_client.api_key
req['email'] = zulip_client.email
zulip_client.do_api_query(req, zulip.API_VERSTRING + "external/github")