Skip to content

Commit be03b1c

Browse files
authored
fix(irc): also remove _ from username for puppets (#196)
1 parent 30203c8 commit be03b1c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

dibridge/irc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ async def _pinger(self):
129129

130130
async def _connect(self):
131131
while True:
132-
try:
133-
username = self._nickname
134-
# An additional constraints usernames have over nicknames, that they are
135-
# also not allowed to start with an underscore.
136-
username = re.sub(r"^_+", "", username)
132+
username = self._nickname
133+
# An additional constraints usernames have over nicknames, that they are
134+
# also not allowed to start with an underscore.
135+
username = re.sub(r"^_+", "", username)
137136

137+
try:
138138
await self.connection.connect(
139139
self._host,
140140
self._port,

dibridge/irc_puppet.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import irc.client_aio
33
import logging
4+
import re
45
import socket
56

67

@@ -139,11 +140,17 @@ async def connect(self):
139140
local_addr = (str(self._ipv6_address), 0)
140141

141142
while self._reconnect:
143+
username = self._nickname
144+
# An additional constraints usernames have over nicknames, that they are
145+
# also not allowed to start with an underscore.
146+
username = re.sub(r"^_+", "", username)
147+
142148
try:
143149
await self.connection.connect(
144150
self._irc_host,
145151
self._irc_port,
146152
self._nickname,
153+
username=username,
147154
# We force an IPv6 connection, as we need that for the puppet source address.
148155
connect_factory=irc.connection.AioFactory(
149156
family=socket.AF_INET6, local_addr=local_addr, ssl=self._irc_port == 6697

0 commit comments

Comments
 (0)