[WORK] v3: встречи в календарь детерминированно; логирование ответов агента
lint / hygiene (push) Successful in 11s
lint / hygiene (push) Successful in 11s
This commit is contained in:
1 parent
1cd6e38adc
commit
51d994abdc
4 files changed
+119
-3
No files matched your search
@@ -115,3 +115,36 @@ def list_todos():
|
||||
return r.read().decode("utf-8", "replace")
|
||||
except Exception as e:
|
||||
return "error: %s" % e
|
||||
|
||||
|
||||
def _ev_ics(item, start, end, place=None):
|
||||
import datetime as _dt
|
||||
now = _dt.datetime.utcnow().strftime("%Y%m%dT%H%M%SZ")
|
||||
fmt = "%Y%m%dT%H%M%S"
|
||||
lines = [
|
||||
"BEGIN:VCALENDAR", "VERSION:2.0",
|
||||
"PRODID:-//Buryans Hub//Work Secretary//RU",
|
||||
"BEGIN:VEVENT",
|
||||
"UID:event-%s@buryans.ru" % item["id"],
|
||||
"DTSTAMP:%s" % now,
|
||||
"DTSTART:%s" % start.strftime(fmt),
|
||||
"DTEND:%s" % end.strftime(fmt),
|
||||
"SUMMARY:%s" % (item.get("text") or "Встреча")[:200].replace("\n", " "),
|
||||
]
|
||||
if place:
|
||||
lines.append("LOCATION:%s" % str(place)[:200])
|
||||
if item.get("partner"):
|
||||
lines.append("DESCRIPTION:Партнёр: %s" % item["partner"])
|
||||
lines += ["END:VEVENT", "END:VCALENDAR", ""]
|
||||
return "\r\n".join(lines)
|
||||
|
||||
|
||||
def put_event(item, start, end, place=None):
|
||||
if not enabled():
|
||||
return 0
|
||||
uid = "event-%s@buryans.ru" % item["id"]
|
||||
return _req("PUT", _url(uid), _ev_ics(item, start, end, place))
|
||||
|
||||
|
||||
def delete_event(item_id):
|
||||
return delete_todo("event-%s@buryans.ru" % item_id)
|
||||
Reference in new issue
Block a user