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
205
Issues
205
List
Boards
Labels
Service Desk
Milestones
Merge Requests
10
Merge Requests
10
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
d1c23999
Verified
Commit
d1c23999
authored
Sep 10, 2019
by
Maxime Buquet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
poezio/mam: style fixes
Signed-off-by:
Maxime “pep” Buquet
<
pep@bouah.net
>
parent
bf37cf5f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
poezio/mam.py
poezio/mam.py
+16
-5
No files found.
poezio/mam.py
View file @
d1c23999
...
...
@@ -32,8 +32,7 @@ def add_line(tab, text_buffer: TextBuffer, text: str, str_time: str, nick: str,
time
=
datetime
.
strptime
(
time
,
'%Y-%m-%d %H:%M:%S'
)
time
=
time
.
replace
(
tzinfo
=
timezone
.
utc
).
astimezone
(
tz
=
None
)
time
=
time
.
replace
(
tzinfo
=
None
)
deterministic
=
config
.
get_by_tabname
(
'deterministic_nick_colors'
,
tab
.
jid
.
bare
)
deterministic
=
config
.
get_by_tabname
(
'deterministic_nick_colors'
,
tab
.
jid
.
bare
)
if
isinstance
(
tab
,
tabs
.
MucTab
):
nick
=
nick
.
split
(
'/'
)[
1
]
user
=
tab
.
get_user_by_name
(
nick
)
...
...
@@ -47,8 +46,7 @@ def add_line(tab, text_buffer: TextBuffer, text: str, str_time: str, nick: str,
color
=
fg_color
,
-
1
else
:
mod
=
len
(
theme
.
LIST_COLOR_NICKNAMES
)
nick_pos
=
int
(
md5
(
nick
.
encode
(
'utf-8'
)).
hexdigest
(),
16
)
%
mod
nick_pos
=
int
(
md5
(
nick
.
encode
(
'utf-8'
)).
hexdigest
(),
16
)
%
mod
color
=
theme
.
LIST_COLOR_NICKNAMES
[
nick_pos
]
else
:
color
=
random
.
choice
(
list
(
xhtml
.
colors
))
...
...
@@ -71,6 +69,7 @@ def add_line(tab, text_buffer: TextBuffer, text: str, str_time: str, nick: str,
jid
=
None
,
)
async
def
query
(
core
,
groupchat
:
bool
,
...
...
@@ -118,6 +117,7 @@ async def query(
return
results
async
def
add_messages_to_buffer
(
tab
,
top
:
bool
,
results
,
amount
:
int
)
->
None
:
"""Prepends or appends messages to the tab text_buffer"""
...
...
@@ -152,6 +152,7 @@ async def add_messages_to_buffer(tab, top: bool, results, amount: int) -> None:
tab
.
core
.
refresh_window
()
return
False
async
def
fetch_history
(
tab
,
end
:
Optional
[
datetime
]
=
None
,
amount
:
Optional
[
int
]
=
None
):
remote_jid
=
tab
.
jid
before
=
tab
.
last_stanza_id
...
...
@@ -167,10 +168,19 @@ async def fetch_history(tab, end: Optional[datetime] = None, amount: Optional[in
groupchat
=
isinstance
(
tab
,
tabs
.
MucTab
)
results
=
await
query
(
tab
.
core
,
groupchat
,
remote_jid
,
amount
,
reverse
=
True
,
end
=
end
,
before
=
before
)
results
=
await
query
(
tab
.
core
,
groupchat
,
remote_jid
,
amount
,
reverse
=
True
,
end
=
end
,
before
=
before
,
)
query_status
=
await
add_messages_to_buffer
(
tab
,
True
,
results
,
amount
)
tab
.
query_status
=
query_status
async
def
on_tab_open
(
tab
)
->
None
:
amount
=
2
*
tab
.
text_win
.
height
end
=
datetime
.
now
()
...
...
@@ -184,6 +194,7 @@ async def on_tab_open(tab) -> None:
except
(
NoMAMSupportException
,
MAMQueryException
,
DiscoInfoException
):
return
None
async
def
on_scroll_up
(
tab
)
->
None
:
amount
=
tab
.
text_win
.
height
try
:
...
...
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