patch 45b2ab79cbf0c21382ec472fd8726cfeacdb9bc1
Author: E. Bosch <presidev@AT@gmail.com>
Date: Fri Jan 29 00:28:55 CET 2021
* irc: Improve users data structure in IRCHandler
diff -rN -u old-irgramd/irc.py new-irgramd/irc.py
--- old-irgramd/irc.py 2024-11-23 02:24:51.099290686 +0100
+++ new-irgramd/irc.py 2024-11-23 02:24:51.099290686 +0100
@@ -38,7 +38,7 @@
self.ioloop = tornado.ioloop.IOLoop.current()
self.hostname = socket.gethostname()
self.config_dir = config_dir
- self.users = []
+ self.users = {}
# Initialize IRC
self.initialize_irc()
@@ -46,7 +46,6 @@
async def run(self, stream, address):
user = IRCUser(stream, address)
- self.users.append(user)
self.logger.debug('Running client connection from %s', user.address)
@@ -114,10 +113,11 @@
if not user.valid_nick(nick):
await self.reply(user, 'ERR_ERRONEUSNICKNAME')
- elif nick in [x.irc_nick for x in self.users if x is not user]:
+ elif nick in self.users.keys():
await self.reply(user, 'ERR_NICKNAMEINUSE')
elif user.password == user.recv_pass:
user.irc_nick = nick
+ self.users[nick] = user
if user.irc_nick in self.iid_to_tid:
tid = self.iid_to_tid[user.irc_nick]
diff -rN -u old-irgramd/telegram.py new-irgramd/telegram.py
--- old-irgramd/telegram.py 2024-11-23 02:24:51.099290686 +0100
+++ new-irgramd/telegram.py 2024-11-23 02:24:51.099290686 +0100
@@ -127,7 +127,7 @@
nick = await self.get_irc_nick_from_telegram_id(event.sender_id)
for message in event.message.message.splitlines():
- for user in self.irc.users:
+ for user in self.irc.users.values():
await self.irc.send_irc_command(user, ':{} PRIVMSG {} :{}'.format(
self.irc.get_irc_user_mask(nick), user.irc_nick, message
))
@@ -156,7 +156,7 @@
# Send all messages to IRC
for message in messages:
- for user in self.irc.users:
+ for user in self.irc.users.values():
await self.irc.send_irc_command(user, ':{} PRIVMSG {} :{}'.format(
self.irc.get_irc_user_mask(nick), channel, message
))