Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def build_identifier(self, txtrep):
log.debug("Build identifier from [%s]" % txtrep)
# A textual representation starting with # means that we are talking
# about an IRC channel -- IRCRoom in internal err-speak.
if txtrep.startswith('#'):
return IRCRoom(txtrep, self)
# Occupants are represented as 2 lines, one is the IRC mask and the second is the Room.
if '\n' in txtrep:
m, r = txtrep.split('\n')
return IRCRoomOccupant(m, IRCRoom(r, self))
return IRCPerson(txtrep)
def __eq__(self, other):
if not isinstance(other, IRCPerson):
log.warning("Weird you are comparing an IRCPerson to a %s.", type(other))
return False
return self.person == other.person
def build_reply(self, msg, text=None, private=False, threaded=False):
response = self.build_message(text)
if msg.is_group:
if private:
response.frm = self.bot_identifier
response.to = IRCPerson(str(msg.frm))
else:
response.frm = IRCRoomOccupant(str(self.bot_identifier), msg.frm.room)
response.to = msg.frm.room
else:
response.frm = self.bot_identifier
response.to = msg.frm
return response
host=self._nickmask.host)
def __unicode__(self):
return str(self._nickmask)
def __str__(self):
return self.__unicode__()
def __eq__(self, other):
if not isinstance(other, IRCPerson):
log.warning("Weird you are comparing an IRCPerson to a %s.", type(other))
return False
return self.person == other.person
class IRCRoomOccupant(IRCPerson, RoomOccupant):
def __init__(self, mask, room):
super().__init__(mask)
self._room = room
@property
def room(self):
return self._room
def __unicode__(self):
return "%s" % self._nickmask
def __str__(self):
return self.__unicode__()
def __repr__(self):
def _privmsg(self, e, notice=False):
msg = Message(e.arguments[0], extras={'notice': notice})
msg.frm = IRCPerson(e.source)
msg.to = IRCPerson(e.target)
self.bot.callback_message(msg)
def _privmsg(self, e, notice=False):
msg = Message(e.arguments[0], extras={'notice': notice})
msg.frm = IRCPerson(e.source)
msg.to = IRCPerson(e.target)
self.bot.callback_message(msg)
password = identity.get('password', None)
ssl = identity.get('ssl', False)
bind_address = identity.get('bind_address', None)
ipv6 = identity.get('ipv6', False)
username = identity.get('username', None)
nickserv_password = identity.get('nickserv_password', None)
compact = config.COMPACT_OUTPUT if hasattr(config, 'COMPACT_OUTPUT') else True
enable_format('irc', IRC_CHRS, borders=not compact)
private_rate = getattr(config, 'IRC_PRIVATE_RATE', 1)
channel_rate = getattr(config, 'IRC_CHANNEL_RATE', 1)
reconnect_on_kick = getattr(config, 'IRC_RECONNECT_ON_KICK', 5)
reconnect_on_disconnect = getattr(config, 'IRC_RECONNECT_ON_DISCONNECT', 5)
self.bot_identifier = IRCPerson(nickname + '!' + nickname + '@' + server)
super().__init__(config)
self.conn = IRCConnection(bot=self,
nickname=nickname,
server=server,
port=port,
ssl=ssl,
bind_address=bind_address,
ipv6=ipv6,
password=password,
username=username,
nickserv_password=nickserv_password,
private_rate=private_rate,
channel_rate=channel_rate,
reconnect_on_kick=reconnect_on_kick,
reconnect_on_disconnect=reconnect_on_disconnect,
)