Useful default typeclass for channels added. Handles poses and provides interfaces for external messages and internal alike.

This commit is contained in:
Kelketek 2013-09-29 13:11:10 -05:00
parent 851e6d00cc
commit 48bcb9d0ba
7 changed files with 267 additions and 107 deletions

View file

@ -52,9 +52,10 @@ class IRC_Bot(irc.IRCClient):
msg_info(msg)
logger.log_infomsg(msg)
def privmsg(self, user, irc_channel, msg):
"Someone has written something in irc channel. Echo it to the evennia channel"
def get_mesg_info(self, user, irc_channel, msg):
"""
Get basic information about a message posted in IRC.
"""
#find irc->evennia channel mappings
conns = ExternalChannelConnection.objects.filter(db_external_key=self.factory.key)
if not conns:
@ -65,28 +66,31 @@ class IRC_Bot(irc.IRCClient):
user.strip()
else:
user = _("Unknown")
msg = "[%s] %s@%s: %s" % (self.factory.evennia_channel, user, irc_channel, msg.strip())
msg = msg.strip()
sender_strings = ["%s@%s" % (user, irc_channel)]
return conns, msg, sender_strings
def privmsg(self, user, irc_channel, msg):
"Someone has written something in irc channel. Echo it to the evennia channel"
conns, msg, sender_strings = self.get_mesg_info(user, irc_channel, msg)
#logger.log_infomsg("<IRC: " + msg)
for conn in conns:
if conn.channel:
conn.to_channel(msg)
conn.to_channel(msg, sender_strings=sender_strings)
def action(self, user, irc_channel, msg):
"Someone has performed an action, e.g. using /me <pose>"
#find irc->evennia channel mappings
conns = ExternalChannelConnection.objects.filter(db_external_key=self.factory.key)
if not conns:
return
#format message:
user = user.split("!")[0]
if user:
user.strip()
else:
user = _("Unknown")
msg = "[%s] *%s@%s %s*" % (self.factory.evennia_channel, user, irc_channel, msg.strip())
conns, msg, sender_strings = self.get_mesg_info(user, irc_channel, msg)
# Transform this into a pose.
msg = ':' + msg
#logger.log_infomsg("<IRC: " + msg)
for conn in conns:
if conn.channel:
conn.to_channel(msg)
conn.to_channel(msg, sender_strings=sender_strings)
def msg_irc(self, msg, senders=None):
"""