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
204
Issues
204
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
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
ab690bbd
Commit
ab690bbd
authored
Feb 04, 2021
by
Link Mauve
Committed by
mathieui
Feb 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core commands: make /last_activity async
parent
ac96beb2
Pipeline
#3660
passed with stages
in 5 minutes and 17 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
poezio/core/commands.py
poezio/core/commands.py
+25
-27
No files found.
poezio/core/commands.py
View file @
ab690bbd
...
...
@@ -902,43 +902,41 @@ class CommandCore:
tab
.
join
()
@
command_args_parser
.
quoted
(
1
)
def
last_activity
(
self
,
args
):
async
def
last_activity
(
self
,
args
):
"""
/last_activity <jid>
"""
def
callback
(
iq
):
"Callback for the last activity"
if
iq
[
'type'
]
!=
'result'
:
if
iq
[
'error'
][
'type'
]
==
'auth'
:
self
.
core
.
information
(
'You are not allowed to see the '
'activity of this contact.'
,
'Error'
)
else
:
self
.
core
.
information
(
'Error retrieving the activity'
,
'Error'
)
return
seconds
=
iq
[
'last_activity'
][
'seconds'
]
status
=
iq
[
'last_activity'
][
'status'
]
from_
=
iq
[
'from'
]
if
not
from_
.
user
:
msg
=
'The uptime of %s is %s.'
%
(
from_
,
common
.
parse_secs_to_str
(
seconds
))
else
:
msg
=
'The last activity of %s was %s ago%s'
%
(
from_
,
common
.
parse_secs_to_str
(
seconds
),
(
' and their last status was %s'
%
status
)
if
status
else
''
)
self
.
core
.
information
(
msg
,
'Info'
)
if
args
is
None
:
return
self
.
help
(
'last_activity'
)
try
:
jid
=
JID
(
args
[
0
])
except
InvalidJID
:
return
self
.
core
.
information
(
'Invalid JID for /last_activity: %s'
%
args
[
0
],
'Error'
)
self
.
core
.
xmpp
.
plugin
[
'xep_0012'
].
get_last_activity
(
jid
,
callback
=
callback
)
try
:
await
self
.
core
.
xmpp
.
plugin
[
'xep_0012'
].
get_last_activity
(
jid
)
except
IqError
as
error
:
if
error
.
etype
==
'auth'
:
msg
=
'You are not allowed to see the activity of %s'
%
jid
else
:
msg
=
'Error retrieving the activity of %s: %s'
%
(
jid
,
error
)
return
self
.
core
.
information
(
msg
,
'Error'
)
except
IqTimeout
:
return
self
.
core
.
information
(
'Timeout while retrieving the last activity of %s'
%
jid
,
'Error'
)
seconds
=
iq
[
'last_activity'
][
'seconds'
]
status
=
iq
[
'last_activity'
][
'status'
]
from_
=
iq
[
'from'
]
if
not
from_
.
user
:
msg
=
'The uptime of %s is %s.'
%
(
from_
,
common
.
parse_secs_to_str
(
seconds
))
else
:
msg
=
'The last activity of %s was %s ago%s'
%
(
from_
,
common
.
parse_secs_to_str
(
seconds
),
(
' and their last status was %s'
%
status
)
if
status
else
''
)
self
.
core
.
information
(
msg
,
'Info'
)
@
command_args_parser
.
quoted
(
0
,
2
)
def
mood
(
self
,
args
):
...
...
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