Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
changed order of attachment "photo". Now will send biggest image if can
Browse files Browse the repository at this point in the history
added support of forwaded messages in the forwarded message (with depth < 5)
  • Loading branch information
mrDoctorWho committed Sep 29, 2013
1 parent 9f02520 commit c27fbaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion extensions/attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def parseAttachments(self, msg):
att[key]["from_id"] = abs(att[key]["from_id"])
body += "https://vk.com/public%(from_id)s?w=wall-%(from_id)s_%(id)s"
elif key == "photo":
keys = ("src_big", "url", "src_xxxbig", "src_xxbig", "src_xbig", "src", "src_small")
keys = ("src_xxxbig", "src_xxbig", "src_xbig", "src_big", "src", "url", "src_small")
for dKey in keys:
if att[key].has_key(dKey):
body += "\n" + att[key][dKey]
Expand Down
7 changes: 5 additions & 2 deletions extensions/forwardMessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
if not require("attachments"):
raise

def parseForwardMessages(self, msg):
def parseForwardMessages(self, msg, depth = 0):
body = ""
if msg.has_key("fwd_messages"):
body += _("\nForward messages:")
fwd_messages = sorted(msg["fwd_messages"], msgSort)
for fwd in fwd_messages:
idFrom = fwd["uid"]
date = fwd["date"]
fwdBody = uHTML(fwd["body"])
fwdBody = escapeMsg(uHTML(fwd["body"]))
date = datetime.fromtimestamp(date).strftime("%d.%m.%Y %H:%M:%S")
name = self.getUserName(idFrom)
body += "\n[%s] <%s> %s" % (date, name, fwdBody)
body += parseAttachments(self, fwd)
if depth < 5: # depth = 4
depth += 1
body += parseForwardMessages(self, fwd, depth)
return body

Handlers["msg01"].append(parseForwardMessages)

0 comments on commit c27fbaf

Please sign in to comment.