@@ -594,8 +594,7 @@ async def handle_topic(self, params: list[str]) -> None:
594594 raise IRCError (ERR .CHANOPRIVSNEEDED , [channel , "You're not a channel operator" ])
595595
596596 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 ()))])
599598
600599 async def handle_names (self , params : list [str ]) -> None :
601600 """Handle the NAMES command.
@@ -800,13 +799,17 @@ def channels(self) -> Iterable[str]:
800799 """Return a list of all the channel names known to the server."""
801800 return list (self ._channels )
802801
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+
803807 async def broadcast (self , target : str , msg : str ) -> None :
804808 """Broadcast a message to all clients that have joined a channel.
805809
806810 The source of the message is the bot's name.
807811 """
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 ))
810813
811814 clients = self ._channels .setdefault (target , set ())
812815 for client in clients :
0 commit comments