-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
70 lines (65 loc) · 1.91 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import time
import requests
import json
import random
payload = {
"data": "my name's sanyam@jain is sam asea",
"message": {
"id": 191404088,
"sender_id": 254216,
"content": "+ task 231751",
"recipient_id": 433815,
"timestamp": 1584894647,
"client": "website",
"subject": "",
"topic_links": [],
"rendered_content": "<p>Hi</p>",
"is_me_message": False,
"reactions": [],
"submessages": [],
"sender_full_name": "sanyam",
"sender_short_name": "sanyam.inbox",
"sender_email": "sanyam.inbox@gmail.com",
"sender_realm_str": "wikimedia",
"display_recipient": [
{
"email": "sanyam.inbox@gmail.com",
"full_name": "sanyam",
"short_name": "sanyam.inbox",
"id": 254216,
"is_mirror_dummy": False
},
{
"id": 274271,
"email": "wikibot-bot@zulipchat.com",
"full_name": "wikibot",
"short_name": "wikibot-bot",
"is_mirror_dummy": False
}
],
"type": "private",
"avatar_url": "https://secure.gravatar.com/avatar/d8f78109444fc5ec90ca174923b580c9?d=identicon&version=1",
"content_type": "text/x-markdown"
},
"bot_email": "wikibot-bot@zulipchat.com",
"token": "v3BmJRGVB4Ec6pTOTi5gEqghSZKWQ275",
"trigger": "private_message"
}
url = 'http://127.0.0.1:5000/api'
temp = 'This is the default message'
while True:
message = input('you : ')
if message == 'quit' or message == 'q':
print('User exited with quit')
break
if message == '':
message = temp
temp = message
payload['message']['id'] = random.randrange(100000000,999999999,1)
payload['message']['content'] = message
headers = {'content-type': 'application/json'}
start = time.time()
response = requests.post(url, data=json.dumps(payload), headers=headers)
end = time.time()
time_required = end-start
print('wikibot : '+response.text+'\n(message fetched in '+str(time_required)+' seconds)')