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
0221081b
Commit
0221081b
authored
Feb 16, 2021
by
mathieui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
irc plugin: Fix the joining code
Make things async
parent
67c5bee9
Pipeline
#3710
passed with stages
in 5 minutes and 9 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
plugins/irc.py
plugins/irc.py
+19
-12
No files found.
plugins/irc.py
View file @
0221081b
...
@@ -129,6 +129,8 @@ Example configuration
...
@@ -129,6 +129,8 @@ Example configuration
"""
"""
import
asyncio
from
poezio.plugin
import
BasePlugin
from
poezio.plugin
import
BasePlugin
from
poezio.decorators
import
command_args_parser
from
poezio.decorators
import
command_args_parser
from
poezio.core.structs
import
Completion
from
poezio.core.structs
import
Completion
...
@@ -139,7 +141,9 @@ from poezio import tabs
...
@@ -139,7 +141,9 @@ from poezio import tabs
class
Plugin
(
BasePlugin
):
class
Plugin
(
BasePlugin
):
def
init
(
self
):
def
init
(
self
):
if
self
.
config
.
get
(
'initial_connect'
,
True
):
if
self
.
config
.
get
(
'initial_connect'
,
True
):
self
.
initial_connect
()
asyncio
.
ensure_future
(
self
.
initial_connect
()
)
self
.
api
.
add_command
(
self
.
api
.
add_command
(
'irc_login'
,
'irc_login'
,
...
@@ -179,17 +183,20 @@ class Plugin(BasePlugin):
...
@@ -179,17 +183,20 @@ class Plugin(BasePlugin):
'example.com "hi there"`'
),
'example.com "hi there"`'
),
short
=
'Open a private conversation with an IRC user'
)
short
=
'Open a private conversation with an IRC user'
)
def
join
(
self
,
gateway
,
server
):
async
def
join
(
self
,
gateway
,
server
):
"Join irc rooms on a server"
"Join irc rooms on a server"
nick
=
self
.
config
.
get_by_tabname
(
nick
=
self
.
config
.
get_by_tabname
(
'nickname'
,
server
,
default
=
''
)
or
self
.
core
.
own_nick
'nickname'
,
server
,
default
=
''
)
or
self
.
core
.
own_nick
rooms
=
self
.
config
.
get_by_tabname
(
rooms
=
self
.
config
.
get_by_tabname
(
'rooms'
,
server
,
default
=
''
).
split
(
':'
)
'rooms'
,
server
,
default
=
''
).
split
(
':'
)
joins
=
[]
for
room
in
rooms
:
for
room
in
rooms
:
room
=
'{}%{}@{}/{}'
.
format
(
room
,
server
,
gateway
,
nick
)
room
=
'{}%{}@{}/{}'
.
format
(
room
,
server
,
gateway
,
nick
)
self
.
core
.
command
.
join
(
room
)
joins
.
append
(
self
.
core
.
command
.
join
(
room
))
await
asyncio
.
gather
(
*
joins
)
def
initial_connect
(
self
):
async
def
initial_connect
(
self
):
gateway
=
self
.
config
.
get
(
'gateway'
,
'irc.poez.io'
)
gateway
=
self
.
config
.
get
(
'gateway'
,
'irc.poez.io'
)
sections
=
self
.
config
.
sections
()
sections
=
self
.
config
.
sections
()
...
@@ -229,7 +236,7 @@ class Plugin(BasePlugin):
...
@@ -229,7 +236,7 @@ class Plugin(BasePlugin):
login
(
gateway
,
section
,
login_nick
,
login_command
,
login
(
gateway
,
section
,
login_nick
,
login_command
,
room_suffix
[
1
:])
room_suffix
[
1
:])
elif
not
already_opened
:
elif
not
already_opened
:
self
.
join
(
gateway
,
section
)
await
self
.
join
(
gateway
,
section
)
@
command_args_parser
.
quoted
(
0
,
-
1
)
@
command_args_parser
.
quoted
(
0
,
-
1
)
def
command_irc_login
(
self
,
args
):
def
command_irc_login
(
self
,
args
):
...
@@ -299,7 +306,7 @@ class Plugin(BasePlugin):
...
@@ -299,7 +306,7 @@ class Plugin(BasePlugin):
return
Completion
(
the_input
.
new_completion
,
sections
,
pos
)
return
Completion
(
the_input
.
new_completion
,
sections
,
pos
)
@
command_args_parser
.
quoted
(
1
,
1
)
@
command_args_parser
.
quoted
(
1
,
1
)
def
command_irc_join
(
self
,
args
):
async
def
command_irc_join
(
self
,
args
):
"""
"""
/irc_join <room or server>
/irc_join <room or server>
"""
"""
...
@@ -310,9 +317,9 @@ class Plugin(BasePlugin):
...
@@ -310,9 +317,9 @@ class Plugin(BasePlugin):
sections
.
remove
(
'irc'
)
sections
.
remove
(
'irc'
)
if
args
[
0
]
in
sections
and
self
.
config
.
get_by_tabname
(
if
args
[
0
]
in
sections
and
self
.
config
.
get_by_tabname
(
'rooms'
,
args
[
0
]):
'rooms'
,
args
[
0
]):
self
.
join_server_rooms
(
args
[
0
])
await
self
.
join_server_rooms
(
args
[
0
])
else
:
else
:
self
.
join_room
(
args
[
0
])
await
self
.
join_room
(
args
[
0
])
@
command_args_parser
.
quoted
(
1
,
1
)
@
command_args_parser
.
quoted
(
1
,
1
)
def
command_irc_query
(
self
,
args
):
def
command_irc_query
(
self
,
args
):
...
@@ -336,7 +343,7 @@ class Plugin(BasePlugin):
...
@@ -336,7 +343,7 @@ class Plugin(BasePlugin):
else
:
else
:
self
.
core
.
command
.
message
(
'{}'
.
format
(
jid
))
self
.
core
.
command
.
message
(
'{}'
.
format
(
jid
))
def
join_server_rooms
(
self
,
section
):
async
def
join_server_rooms
(
self
,
section
):
"""
"""
Join all the rooms configured for a section
Join all the rooms configured for a section
(section = irc server)
(section = irc server)
...
@@ -351,9 +358,9 @@ class Plugin(BasePlugin):
...
@@ -351,9 +358,9 @@ class Plugin(BasePlugin):
suffix
=
'%{}@{}{}'
.
format
(
section
,
gateway
,
nick
)
suffix
=
'%{}@{}{}'
.
format
(
section
,
gateway
,
nick
)
for
room
in
rooms
:
for
room
in
rooms
:
self
.
core
.
command
.
join
(
room
+
suffix
)
await
self
.
core
.
command
.
join
(
room
+
suffix
)
def
join_room
(
self
,
name
):
async
def
join_room
(
self
,
name
):
"""
"""
Join a room with only its name and the current tab
Join a room with only its name and the current tab
"""
"""
...
@@ -366,7 +373,7 @@ class Plugin(BasePlugin):
...
@@ -366,7 +373,7 @@ class Plugin(BasePlugin):
if
self
.
config
.
get_by_tabname
(
'nickname'
,
server
):
if
self
.
config
.
get_by_tabname
(
'nickname'
,
server
):
room
+=
'/'
+
self
.
config
.
get_by_tabname
(
'nickname'
,
server
)
room
+=
'/'
+
self
.
config
.
get_by_tabname
(
'nickname'
,
server
)
self
.
core
.
command
.
join
(
room
)
await
self
.
core
.
command
.
join
(
room
)
def
get_current_tab_irc_info
(
self
):
def
get_current_tab_irc_info
(
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