-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdelaymessage.py
33 lines (27 loc) · 959 Bytes
/
delaymessage.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
#!usr/bin/python
# methods for converting to and from a delay message
from __future__ import unicode_literals
def make_delay_message(dateStored, timestamp, date, user, stream, topic, message):
"""
Creates an instance of a delaymessage with all data
it needs a date when it was stored, unix timestamp, date,
username, stream and topic to respond in, and message to send
"""
return {
"dateStored": dateStored,
"timestamp": timestamp,
"date": date,
"user": user,
"stream": stream,
"topic": topic,
"message": message
}
def make_zulip_message(dm):
"""Converts a delaymessage into a public zulip message"""
message = {}
message["type"] = "stream"
message["to"] = dm["stream"]
message["subject"] = dm["topic"]
message["content"] = "%s\n- from @**%s** at %s (Eastern Time)" % (
dm["message"], dm["user"], dm["dateStored"])
return message