Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mrDoctorWho/vk4xmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Smith <mrdoctorwho@helldev.net>2020-09-07 16:38:25 +0300
committerJohn Smith <mrdoctorwho@helldev.net>2020-09-07 16:38:25 +0300
commitbf2a3db0697124bd7e2620a501a7181523f03c5e (patch)
treeb74426ffd46ed2f19704558be4a17082a27ceb55
parent656fdba28d372d7e37c81042823e9df07f77fa34 (diff)
Add reply plugin; ignore messages from groupchats if creation failed
-rw-r--r--extensions/groupchats.py4
-rw-r--r--extensions/reply.py26
2 files changed, 28 insertions, 2 deletions
diff --git a/extensions/groupchats.py b/extensions/groupchats.py
index 9eaef8c..16bf299 100644
--- a/extensions/groupchats.py
+++ b/extensions/groupchats.py
@@ -150,7 +150,7 @@ def handleOutgoingChatMessage(user, vkChat):
if chatID > 0:
# check if the groupchats support enabled in user's settings
if not user.settings.groupchats:
- return None
+ return (MSG_SKIP, "")
if not hasattr(user, "chats"):
user.chats = {}
@@ -166,7 +166,7 @@ def handleOutgoingChatMessage(user, vkChat):
chat.init(owner, chatID, chatJID, title, time.time(), users)
if not chat.created:
if chat.creation_failed:
- return None
+ return (MSG_SKIP, "")
# we can add user, vkChat to the create() method to prevent losing or messing up the messages
chat.create(user)
# read the comments above the handleMessage function
diff --git a/extensions/reply.py b/extensions/reply.py
new file mode 100644
index 0000000..4855164
--- /dev/null
+++ b/extensions/reply.py
@@ -0,0 +1,26 @@
+# coding: utf-8
+# This file is a part of VK4XMPP transport
+# © simpleApps, 2020.
+
+
+def parseReplyMessages(self, msg):
+ body = ""
+ result = (MSG_APPEND, "")
+ if msg.get("reply_message"):
+ # todo: add date if the message wasn't sent today
+ reply = msg["reply_message"]
+ text = escape("", uhtml(reply["text"]))
+ attachments = parseAttachments(self, reply)[1]
+ forwarded_messages = parseForwardedMessages(self, reply)[1]
+ if text:
+ body += "> " + text
+ if attachments:
+ body += "> " + attachments
+ if forwarded_messages:
+ body += forwarded_messages.replace("\n", "\n>")
+ body += "\n"
+ result = (MSG_PREPEND, body)
+ return result
+
+
+registerHandler("msg01", parseReplyMessages) \ No newline at end of file