Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
poezio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
175
Issues
175
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poezio
poezio
Commits
ddc23d7d
Commit
ddc23d7d
authored
Aug 13, 2019
by
Madhur Garg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added user colors for messages retrieved using MAM
parent
f496be64
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
poezio/mam.py
poezio/mam.py
+18
-12
No files found.
poezio/mam.py
View file @
ddc23d7d
...
...
@@ -7,20 +7,34 @@
"""
import
asyncio
import
random
from
datetime
import
datetime
,
timedelta
,
timezone
from
slixmpp.exceptions
import
IqError
,
IqTimeout
from
poezio.theming
import
get_theme
from
poezio
import
tabs
from
poezio
import
xhtml
from
poezio.config
import
config
from
poezio.text_buffer
import
Message
,
TextBuffer
def
add_line
(
text_buffer
:
TextBuffer
,
text
:
str
,
str_time
:
str
,
nick
:
str
,
top
:
bool
):
def
add_line
(
t
ab
,
t
ext_buffer
:
TextBuffer
,
text
:
str
,
str_time
:
str
,
nick
:
str
,
top
:
bool
):
"""Adds a textual entry in the TextBuffer"""
time
=
datetime
.
strftime
(
str_time
,
'%Y-%m-%d %H:%M:%S'
)
time
=
datetime
.
strptime
(
time
,
'%Y-%m-%d %H:%M:%S'
)
time
=
time
.
replace
(
tzinfo
=
timezone
.
utc
).
astimezone
(
tz
=
None
)
time
=
time
.
replace
(
tzinfo
=
None
)
color
=
get_theme
().
COLOR_OWN_NICK
if
isinstance
(
tab
,
tabs
.
MucTab
):
nick
=
nick
.
split
(
'/'
)[
1
]
user
=
tab
.
get_user_by_name
(
nick
)
if
user
:
color
=
user
.
color
else
:
color
=
random
.
choice
(
list
(
xhtml
.
colors
))
color
=
xhtml
.
colors
.
get
(
color
)
color
=
(
color
,
-
1
)
else
:
nick
=
nick
.
split
(
'/'
)[
0
]
color
=
get_theme
().
COLOR_OWN_NICK
text_buffer
.
add_message
(
text
,
time
,
...
...
@@ -97,11 +111,7 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None):
message
=
forwarded
[
'stanza'
]
tab
.
stanza_id
=
msg
[
'mam_result'
][
'id'
]
nick
=
str
(
message
[
'from'
])
if
isinstance
(
tab
,
tabs
.
MucTab
):
nick
=
nick
.
split
(
'/'
)[
1
]
else
:
nick
=
nick
.
split
(
'/'
)[
0
]
add_line
(
text_buffer
,
message
[
'body'
],
timestamp
,
nick
,
top
)
add_line
(
tab
,
text_buffer
,
message
[
'body'
],
timestamp
,
nick
,
top
)
tab
.
text_win
.
scroll_up
(
len
(
tab
.
text_win
.
built_lines
))
else
:
for
msg
in
rsm
[
'mam'
][
'results'
]:
...
...
@@ -109,11 +119,7 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None):
timestamp
=
forwarded
[
'delay'
][
'stamp'
]
message
=
forwarded
[
'stanza'
]
nick
=
str
(
message
[
'from'
])
if
'conference'
in
list
(
iq
[
'disco_info'
][
'identities'
])[
0
]:
nick
=
nick
.
split
(
'/'
)[
1
]
else
:
nick
=
nick
.
split
(
'/'
)[
0
]
add_line
(
text_buffer
,
message
[
'body'
],
timestamp
,
nick
,
top
)
add_line
(
tab
,
text_buffer
,
message
[
'body'
],
timestamp
,
nick
,
top
)
tab
.
core
.
refresh_window
()
if
len
(
msgs
)
==
0
:
return
tab
.
core
.
information
(
'No more messages left to retrieve'
,
'Info'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment