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
199
Issues
199
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
048f3d5f
Commit
048f3d5f
authored
Jan 30, 2021
by
mathieui
Committed by
Link Mauve
Feb 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core commands: remove uses of callback=
parent
19b58d86
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
34 deletions
+61
-34
poezio/core/commands.py
poezio/core/commands.py
+61
-34
No files found.
poezio/core/commands.py
View file @
048f3d5f
...
@@ -301,27 +301,40 @@ class CommandCore:
...
@@ -301,27 +301,40 @@ class CommandCore:
jid
=
self
.
core
.
tabs
.
current_tab
.
jid
jid
=
self
.
core
.
tabs
.
current_tab
.
jid
if
jid
is
None
or
not
jid
.
domain
:
if
jid
is
None
or
not
jid
.
domain
:
return
None
return
None
asyncio
.
ensure_future
(
self
.
_list_async
(
jid
)
)
async
def
_list_async
(
self
,
jid
:
JID
):
jid
=
JID
(
jid
.
domain
)
jid
=
JID
(
jid
.
domain
)
list_tab
=
tabs
.
MucListTab
(
self
.
core
,
jid
)
list_tab
=
tabs
.
MucListTab
(
self
.
core
,
jid
)
self
.
core
.
add_tab
(
list_tab
,
True
)
self
.
core
.
add_tab
(
list_tab
,
True
)
cb
=
list_tab
.
on_muc_list_item_received
iq
=
await
self
.
core
.
xmpp
.
plugin
[
'xep_0030'
].
get_items
(
jid
=
jid
)
self
.
core
.
xmpp
.
plugin
[
'xep_0030'
].
get_items
(
jid
=
jid
,
callback
=
cb
)
list_tab
.
on_muc_list_item_received
(
iq
)
@
command_args_parser
.
quoted
(
1
)
@
command_args_parser
.
quoted
(
1
)
def
version
(
self
,
args
):
async
def
version
(
self
,
args
):
"""
"""
/version <jid>
/version <jid>
"""
"""
if
args
is
None
:
if
args
is
None
:
return
self
.
help
(
'version'
)
return
self
.
help
(
'version'
)
jid
=
safeJID
(
args
[
0
])
try
:
jid
=
JID
(
args
[
0
])
except
InvalidJID
:
return
self
.
core
.
information
(
'Invalid JID for /version: %s'
%
args
[
0
],
'Error'
)
if
jid
.
resource
or
jid
not
in
roster
or
not
roster
[
jid
].
resources
:
if
jid
.
resource
or
jid
not
in
roster
or
not
roster
[
jid
].
resources
:
self
.
core
.
xmpp
.
plugin
[
'xep_0092'
].
get_version
(
iq
=
await
self
.
core
.
xmpp
.
plugin
[
'xep_0092'
].
get_version
(
jid
)
jid
,
callback
=
self
.
core
.
handler
.
on_version_result
)
self
.
core
.
handler
.
on_version_result
(
iq
)
elif
jid
in
roster
:
elif
jid
in
roster
:
for
resource
in
roster
[
jid
].
resources
:
for
resource
in
roster
[
jid
].
resources
:
self
.
core
.
xmpp
.
plugin
[
'xep_0092'
].
get_version
(
iq
=
await
self
.
core
.
xmpp
.
plugin
[
'xep_0092'
].
get_version
(
resource
.
jid
,
callback
=
self
.
core
.
handler
.
on_version_result
)
resource
.
jid
)
self
.
core
.
handler
.
on_version_result
(
iq
)
def
_empty_join
(
self
):
def
_empty_join
(
self
):
tab
=
self
.
core
.
tabs
.
current_tab
tab
=
self
.
core
.
tabs
.
current_tab
...
@@ -1049,6 +1062,7 @@ class CommandCore:
...
@@ -1049,6 +1062,7 @@ class CommandCore:
jid
=
JID
(
args
[
0
]).
full
jid
=
JID
(
args
[
0
]).
full
except
InvalidJID
:
except
InvalidJID
:
self
.
core
.
information
(
'Invalid JID %s'
%
args
,
'Error'
)
self
.
core
.
information
(
'Invalid JID %s'
%
args
,
'Error'
)
return
current_tab
=
self
.
core
.
tabs
.
current_tab
current_tab
=
self
.
core
.
tabs
.
current_tab
if
jid
is
None
:
if
jid
is
None
:
...
@@ -1071,20 +1085,20 @@ class CommandCore:
...
@@ -1071,20 +1085,20 @@ class CommandCore:
if
isinstance
(
current_tab
,
chattabs
):
if
isinstance
(
current_tab
,
chattabs
):
jid
=
current_tab
.
jid
.
bare
jid
=
current_tab
.
jid
.
bare
def
callback
(
iq
:
Iq
)
->
None
:
if
jid
is
None
:
if
iq
[
'type'
]
==
'error'
:
return
self
.
core
.
information
(
'Could not block %s.'
%
jid
,
'Error'
,
)
if
iq
[
'type'
]
==
'result'
:
return
self
.
core
.
information
(
'Blocked %s.'
%
jid
,
'Info'
)
return
None
if
jid
is
not
None
:
self
.
core
.
xmpp
.
plugin
[
'xep_0191'
].
block
(
jid
,
callback
=
callback
)
else
:
self
.
core
.
information
(
'No specified JID to block'
,
'Error'
)
self
.
core
.
information
(
'No specified JID to block'
,
'Error'
)
else
:
asyncio
.
ensure_future
(
self
.
_block_async
(
jid
))
async
def
_block_async
(
self
,
jid
:
JID
):
"""Block a JID, asynchronously"""
try
:
await
self
.
core
.
xmpp
.
plugin
[
'xep_0191'
].
block
(
jid
)
return
self
.
core
.
information
(
'Blocked %s.'
%
jid
,
'Info'
)
except
(
IqError
,
IqTimeout
):
return
self
.
core
.
information
(
'Could not block %s.'
%
jid
,
'Error'
,
)
@
command_args_parser
.
quoted
(
0
,
1
)
@
command_args_parser
.
quoted
(
0
,
1
)
def
unblock
(
self
,
args
:
List
[
str
])
->
None
:
def
unblock
(
self
,
args
:
List
[
str
])
->
None
:
...
@@ -1103,6 +1117,7 @@ class CommandCore:
...
@@ -1103,6 +1117,7 @@ class CommandCore:
jid
=
JID
(
args
[
0
]).
full
jid
=
JID
(
args
[
0
]).
full
except
InvalidJID
:
except
InvalidJID
:
self
.
core
.
information
(
'Invalid JID %s'
%
args
,
'Error'
)
self
.
core
.
information
(
'Invalid JID %s'
%
args
,
'Error'
)
return
current_tab
=
self
.
core
.
tabs
.
current_tab
current_tab
=
self
.
core
.
tabs
.
current_tab
if
jid
is
None
:
if
jid
is
None
:
...
@@ -1126,17 +1141,21 @@ class CommandCore:
...
@@ -1126,17 +1141,21 @@ class CommandCore:
jid
=
current_tab
.
jid
.
bare
jid
=
current_tab
.
jid
.
bare
if
jid
is
not
None
:
if
jid
is
not
None
:
def
callback
(
iq
:
Iq
):
asyncio
.
ensure_future
(
if
iq
[
'type'
]
==
'error'
:
self
.
_unblock_async
(
jid
)
return
self
.
core
.
information
(
'Could not unblock the contact.'
,
)
'Error'
)
elif
iq
[
'type'
]
==
'result'
:
return
self
.
core
.
information
(
'Unblocked %s.'
%
jid
,
'Info'
)
self
.
core
.
xmpp
.
plugin
[
'xep_0191'
].
unblock
(
jid
,
callback
=
callback
)
else
:
else
:
self
.
core
.
information
(
'No specified JID to unblock'
,
'Error'
)
self
.
core
.
information
(
'No specified JID to unblock'
,
'Error'
)
async
def
_unblock_async
(
self
,
jid
:
JID
):
"""Unblock a JID, asynchrously"""
try
:
await
self
.
core
.
xmpp
.
plugin
[
'xep_0191'
].
unblock
(
jid
)
return
self
.
core
.
information
(
'Unblocked %s.'
%
jid
,
'Info'
)
except
(
IqError
,
IqTimeout
):
return
self
.
core
.
information
(
'Could not unblock the contact.'
,
'Error'
)
### Commands without a completion in this class ###
### Commands without a completion in this class ###
@
command_args_parser
.
ignored
@
command_args_parser
.
ignored
...
@@ -1344,15 +1363,23 @@ class CommandCore:
...
@@ -1344,15 +1363,23 @@ class CommandCore:
self
.
core
.
xml_tab
=
tab
self
.
core
.
xml_tab
=
tab
@
command_args_parser
.
quoted
(
1
)
@
command_args_parser
.
quoted
(
1
)
def
adhoc
(
self
,
args
):
async
def
adhoc
(
self
,
args
):
if
not
args
:
if
not
args
:
return
self
.
help
(
'ad-hoc'
)
return
self
.
help
(
'ad-hoc'
)
jid
=
safeJID
(
args
[
0
])
try
:
jid
=
JID
(
args
[
0
])
except
InvalidJID
:
return
self
.
core
.
information
(
'Invalid JID for ad-hoc command: %s'
%
args
[
0
],
'Error'
,
)
list_tab
=
tabs
.
AdhocCommandsListTab
(
self
.
core
,
jid
)
list_tab
=
tabs
.
AdhocCommandsListTab
(
self
.
core
,
jid
)
self
.
core
.
add_tab
(
list_tab
,
True
)
self
.
core
.
add_tab
(
list_tab
,
True
)
cb
=
list_tab
.
on_list_received
iq
=
await
self
.
core
.
xmpp
.
plugin
[
'xep_0050'
].
get_commands
(
self
.
core
.
xmpp
.
plugin
[
'xep_0050'
].
get_commands
(
jid
=
jid
,
jid
=
jid
,
local
=
False
,
callback
=
cb
)
local
=
False
)
list_tab
.
on_list_received
(
iq
)
@
command_args_parser
.
ignored
@
command_args_parser
.
ignored
def
self_
(
self
):
def
self_
(
self
):
...
...
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