mirror of
https://github.com/evennia/evennia.git
synced 2026-04-01 13:37:17 +02:00
Remote IMC2 channels can now be listened to via IMC2 bindings. For this to work, create an IMC2ChannelMapping object with the channel you'd like to serve as the gateway to the remote IMC2 channel. Enter the IMC2 channel's name as the imc2_channel_name field and make sure the object is enabled. Any incoming ice-msg-b packets directed at your chosen channel will now be emitted to the appropriate channel as if it were local, with one difference: the user name is sender@origin. Sending messages is hopefully soon to follow.
This commit is contained in:
parent
573d1b6e88
commit
42f11b208b
4 changed files with 43 additions and 0 deletions
|
|
@ -212,6 +212,7 @@ INSTALLED_APPS = (
|
|||
'django.contrib.flatpages',
|
||||
'src.config',
|
||||
'src.objects',
|
||||
'src.imc2',
|
||||
'src.helpsys',
|
||||
'src.genperms',
|
||||
'game.web.apps.news',
|
||||
|
|
|
|||
6
src/imc2/admin.py
Normal file
6
src/imc2/admin.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from src.imc2.models import IMC2ChannelMapping
|
||||
from django.contrib import admin
|
||||
|
||||
class IMC2ChannelMappingAdmin(admin.ModelAdmin):
|
||||
list_display = ('channel', 'imc2_channel_name', 'is_enabled')
|
||||
admin.site.register(IMC2ChannelMapping, IMC2ChannelMappingAdmin)
|
||||
|
|
@ -12,6 +12,8 @@ from src import logger
|
|||
from src.imc2.packets import *
|
||||
from src.imc2.trackers import *
|
||||
from src.imc2 import reply_listener
|
||||
from src.imc2.models import IMC2ChannelMapping
|
||||
from src import comsys
|
||||
|
||||
# The active instance of IMC2Protocol. Set at server startup.
|
||||
IMC2_PROTOCOL_INSTANCE = None
|
||||
|
|
@ -88,6 +90,22 @@ class IMC2Protocol(StatefulTelnetProtocol):
|
|||
logger.log_infomsg(packet)
|
||||
if packet.packet_type == 'is-alive':
|
||||
IMC2_MUDLIST.update_mud_from_packet(packet)
|
||||
elif packet.packet_type == 'ice-msg-b':
|
||||
# Received a message. Look for an IMC2 channel mapping and
|
||||
# route it accordingly.
|
||||
chan_name = packet.optional_data.get('channel', None)
|
||||
if chan_name:
|
||||
chan_name = chan_name.split(':', 1)[1]
|
||||
try:
|
||||
mapping = IMC2ChannelMapping.objects.get(imc2_channel_name=chan_name)
|
||||
ingame_chan_name = mapping.channel.name
|
||||
message = '[%s] %s@%s: %s' % (ingame_chan_name,
|
||||
packet.sender,
|
||||
packet.origin,
|
||||
packet.optional_data.get('text'))
|
||||
comsys.send_cmessage(ingame_chan_name, message)
|
||||
except IMC2ChannelMapping.DoesNotExist:
|
||||
pass
|
||||
elif packet.packet_type == 'whois-reply':
|
||||
reply_listener.handle_whois_reply(packet)
|
||||
elif packet.packet_type == 'close-notify':
|
||||
|
|
|
|||
18
src/imc2/models.py
Normal file
18
src/imc2/models.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
from django.db import models
|
||||
from src.objects.models import CommChannel
|
||||
|
||||
class IMC2ChannelMapping(models.Model):
|
||||
"""
|
||||
Each IMC2ChannelMapping object determines which in-game channel incoming
|
||||
IMC2 messages are routed to.
|
||||
"""
|
||||
channel = models.ForeignKey(CommChannel)
|
||||
imc2_channel_name = models.CharField(max_length=78)
|
||||
is_enabled = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "IMC2 Channel mapping"
|
||||
verbose_name_plural = "IMC2 Channel mappings"
|
||||
|
||||
def __str__(self):
|
||||
return "%s <-> %s" % (self.channel, self.imc2_channel_name)
|
||||
Loading…
Add table
Add a link
Reference in a new issue