@@ -594,8 +594,7 @@ async def handle_topic(self, params: list[str]) -> None:
594
594
raise IRCError (ERR .CHANOPRIVSNEEDED , [channel , "You're not a channel operator" ])
595
595
596
596
await self .msg (RPL .TOPIC , [channel , self .server .topic_tmpl .format (channel = channel )])
597
- botid = self .server .botname + "!" + self .server .botname + "@" + self .server .servername
598
- await self .msg (RPL .TOPICWHOTIME , [channel , botid , str (int (self .server .boot_time .timestamp ()))])
597
+ await self .msg (RPL .TOPICWHOTIME , [channel , self .server .botid , str (int (self .server .boot_time .timestamp ()))])
599
598
600
599
async def handle_names (self , params : list [str ]) -> None :
601
600
"""Handle the NAMES command.
@@ -800,13 +799,17 @@ def channels(self) -> Iterable[str]:
800
799
"""Return a list of all the channel names known to the server."""
801
800
return list (self ._channels )
802
801
802
+ @property
803
+ def botid (self ) -> str :
804
+ """Return the extended prefix of the bot, to be used as e.g. source in PRIVMSG."""
805
+ return self .botname + "!" + self .botname + "@" + self .servername
806
+
803
807
async def broadcast (self , target : str , msg : str ) -> None :
804
808
"""Broadcast a message to all clients that have joined a channel.
805
809
806
810
The source of the message is the bot's name.
807
811
"""
808
- botid = self .botname + "!" + self .botname + "@" + self .servername
809
- message = str (IRCMessage ("PRIVMSG" , [target , msg ], source = botid ))
812
+ message = str (IRCMessage ("PRIVMSG" , [target , msg ], source = self .botid ))
810
813
811
814
clients = self ._channels .setdefault (target , set ())
812
815
for client in clients :
0 commit comments