patch 4e31d63e717768dbe39a3808f54b9e12627a687b
Author: E. Bosch <presidev@AT@gmail.com>
Date: Tue Nov 24 21:11:50 CET 2020
* Remove voices functionality
diff -rN -u old-irgramd/irc.py new-irgramd/irc.py
--- old-irgramd/irc.py 2024-11-23 02:01:26.605505829 +0100
+++ new-irgramd/irc.py 2024-11-23 02:01:26.605505829 +0100
@@ -11,10 +11,6 @@
from utils import chunks
-# Configuration
-
-UPDATE_CHANNEL_VOICES_DELAY = 300
-
# IRC Regular Expressions
IRC_NICK_RX = re.compile(r'NICK :(?P<nick>[^\n\r]+)')
@@ -70,7 +66,6 @@
self.iid_to_tid = {}
self.irc_channels = collections.defaultdict(set)
self.irc_nick = None
- self.irc_voices = collections.defaultdict(set)
def get_irc_user_mask(self, nick):
return '{}!{}@{}'.format(nick, nick, self.hostname)
@@ -138,7 +133,7 @@
# Add all users to channel
tid = self.iid_to_tid[channel]
- nicks, voices = await self.tg.get_telegram_channel_participants(tid)
+ nicks = await self.tg.get_telegram_channel_participants(tid)
# Set channel topic
topic = (await self.tg.telegram_client.get_entity(tid)).title
@@ -152,35 +147,8 @@
self.hostname, self.irc_nick, channel, ' '.join(chunk)
))
- # Update voices
- await self.update_channel_voices(channel, voices)
-
async def part_irc_channel(self, nick, channel):
self.irc_channels[channel].remove(nick)
await self.send_irc_command(':{} PART {} :'.format(
self.get_irc_user_mask(nick), channel
))
-
- async def update_channel_voices(self, channel, voices=None):
- # Get voices for channel if not provided
- if not voices:
- tid = self.iid_to_tid[channel]
- _, voices = await self.tg.get_telegram_channel_participants(tid)
-
- # Add new voices
- for nick in voices:
- if nick not in self.irc_voices[channel]:
- self.irc_voices[channel].add(nick)
- await self.send_irc_command(':{} MODE {} +v {}'.format(
- self.hostname, channel, nick,
- ))
-
- # Remove old voices
- for nick in self.irc_voices[channel].difference(voices):
- self.irc_voices[channel].remove(nick)
- await self.send_irc_command(':{} MODE {} -v {}'.format(
- self.hostname, channel, nick,
- ))
-
- self.ioloop.call_later(UPDATE_CHANNEL_VOICES_DELAY, self.update_channel_voices, channel)
-
diff -rN -u old-irgramd/telegram.py new-irgramd/telegram.py
--- old-irgramd/telegram.py 2024-11-23 02:01:26.605505829 +0100
+++ new-irgramd/telegram.py 2024-11-23 02:01:26.605505829 +0100
@@ -96,17 +96,13 @@
async def get_telegram_channel_participants(self, tid):
channel = self.tid_to_iid[tid]
nicks = []
- voices = set()
async for user in self.telegram_client.iter_participants(tid):
user_nick = await self.get_irc_nick_from_telegram_id(user.id, user)
- if isinstance(user.status, telethon.types.UserStatusOnline):
- voices.add(user_nick)
-
nicks.append(user_nick)
self.irc.irc_channels[channel].add(user_nick)
- return nicks, voices
+ return nicks
async def handle_telegram_message(self, event):
self.logger.debug('Handling Telegram Message: %s', event)