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@gmail.com>2018-12-25 05:16:44 +0300
committerJohn Smith <mrdoctorwho@gmail.com>2018-12-25 05:16:44 +0300
commit9f56f835c706254b242bf8aee8ca6a028c170e40 (patch)
tree4a770866a7119a32ff6e4b0e75218b476bdb63d3
parenta6f02bb396a8166dfb1051692273e5856b21e2bb (diff)
add nicknames to message stanzas from strangers by default
-rw-r--r--extensions/user_nickname.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/extensions/user_nickname.py b/extensions/user_nickname.py
index e13a43b..2d160db 100644
--- a/extensions/user_nickname.py
+++ b/extensions/user_nickname.py
@@ -3,21 +3,20 @@
# © simpleApps, 2015 (27.08.15 09:31AM GMT)
"""
-Implements XEP-0172: User Nickname (apparently, case 4.2)
+Implements XEP-0172: User Nickname (partially, case 4.2)
"""
-GLOBAL_USER_SETTINGS["add_nicknames_msg"] = {"value": 0, "label": "Add nickname to message stanzas from strangers"}
GLOBAL_USER_SETTINGS["add_nicknames_prs"] = {"value": 0, "label": "Add nickname to presence stanzas"}
def add_username(stanza, user, uid):
- if uid != TransportID:
+ if uid == TransportID:
+ name = IDENTIFIER["name"]
+ else:
key = "name"
if user.settings.use_nicknames:
key = "screen_name"
name = user.vk.getUserData(uid)[key]
- else:
- name = IDENTIFIER["name"]
stanza.setTag("nick", namespace=xmpp.NS_NICK)
stanza.setTagData("nick", name)
@@ -25,13 +24,12 @@ def add_username(stanza, user, uid):
def add_nickname_msg03(msg, destination, source):
if destination in Users and source != TransportID: # That would be strange if user wasn't in Transport
user = Users[destination]
- if user.settings.add_nicknames_msg:
- uid = vk2xmpp(source)
- strangers = getattr(user, "strangers", set([]))
- if uid not in strangers and uid not in user.friends:
- add_username(msg, user, uid)
- strangers.add(uid)
- user.strangers = strangers
+ uid = vk2xmpp(source)
+ strangers = getattr(user, "strangers", set([]))
+ if uid not in strangers and uid not in user.friends:
+ add_username(msg, user, uid)
+ strangers.add(uid)
+ user.strangers = strangers
def add_nickname_prs02(prs, destination, source):