def find_channel(caller, channelname, silent=False, noaliases=False):
 channels = ChannelDB.objects.channel_search(channelname)
 if (not channels):
  if (not noaliases):
   channels = [chan for chan in ChannelDB.objects.get_all_channels() if (channelname in chan.aliases.all())]
  if channels:
   return channels[0]
  if (not silent):
   caller.msg(("Channel '%s' not found." % channelname))
  return None
 elif (len(channels) > 1):
  matches = ', '.join([('%s(%s)' % (chan.key, chan.id)) for chan in channels])
  if (not silent):
   caller.msg(('Multiple channels match (be more specific): \n%s' % matches))
  return None
 return channels[0]

def find_channel ( caller , channelname , silent = False , noaliases = False ) : channels = ChannelDB . objects . channel_search ( channelname ) if ( not channels ) : if ( not noaliases ) : channels = [ chan for chan in ChannelDB . objects . get_all_channels ( ) if ( channelname in chan . aliases . all ( ) ) ] if channels : return channels [ 0 ] if ( not silent ) : caller . msg ( ( "Channel '%s' not found." % channelname ) ) return None elif ( len ( channels ) > 1 ) : matches = ', ' . join ( [ ( '%s(%s)' % ( chan . key , chan . id ) ) for chan in channels ] ) if ( not silent ) : caller . msg ( ( 'Multiple channels match (be more specific): \n%s' % matches ) ) return None return channels [ 0 ]
helper function for searching for a single channel with some error handling .