Bans a user from a server

    Args:
        channel: The channel to send the warning message in
        user: The user to give the warning to
976310
async def ban_user(channel, user):
    

    data = datatools.get_data()
    server_id = channel.server.id

    try:
        await client.ban(user)
    except discord.errors.Forbidden:
        await client.send_typing(channel)
        embed = ui_embed.error(channel, "Ban Error", "I do not have the permissions to ban that person.")
        await embed.send()
        return

    # Set the user's warnings to 0
    if "warnings" in data["discord"]["servers"][server_id][_data.modulename]:
        if user.id in data["discord"]["servers"][server_id][_data.modulename]["warnings"]:
            data["discord"]["servers"][server_id][_data.modulename]["warnings"][user.id] = 0
            datatools.write_data(data)

    await client.send_typing(channel)
    embed = ui_embed.user_ban(channel, user)
    await embed.send()

    try:
        response = "You have been banned from the server '{}' " \
                   "contact the owners to resolve this issue.".format(channel.server.name)
        await client.send_message(user, response)
    except Exception as e:
        logger.exception(e)
427614
def kick(self, channel, nick, reason=''):
        
        with self.lock:
            self.is_in_channel(channel)

            self.send('KICK %s %s :%s' % (channel, nick, reason))

            if self.readable():
                msg = self._recv(expected_replies=('KICK',))

                if msg[0] == 'KICK':
                    channel = msg[1]
                    if not self.hide_called_events:
                        self.stepback()

            if self.compare(self.current_nick, nick):
                del self.channels[channel]
1374137
def unsubscribe(self, socket_id, channel):
        """"""
        con = self._get_connection(socket_id, create=False)
        if con is not None:
            con.subscriptions.discard(channel)
        try:
            self.subscriptions[channel].discard(socket_id)
        except KeyError:
            pass
1096619
def warning_max_changed(channel, max_warnings):
    

    # Create embed UI object
    gui = ui_embed.UI(
        channel,
        "Maximum Warnings Changed",
        "Users must now have {} warnings to be banned "
        "(this won't ban existing users with warnings)".format(max_warnings),
        modulename=modulename
    )

    return gui
1146882
def _close_channel(self, frame_in):
        
        if frame_in.reply_code != 200:
            reply_text = try_utf8_decode(frame_in.reply_text)
            message = (
                'Channel %d was closed by remote server: %s' %
                (
                    self._channel_id,
                    reply_text
                )
            )
            exception = AMQPChannelError(message,
                                         reply_code=frame_in.reply_code)
            self.exceptions.append(exception)
        self.set_state(self.CLOSED)
        if self._connection.is_open:

            try:
                self._connection.write_frame(
                    self.channel_id, specification.Channel.CloseOk()
                )
            except AMQPConnectionError:
                pass
        self.close()
357139
def disconnect_channel(self, destination_id):
        
        if destination_id in self._open_channels:
            try:
                self.send_message(
                    destination_id, NS_CONNECTION,
                    {MESSAGE_TYPE: TYPE_CLOSE, 'origin': {}},
                    no_add_request_id=True, force=True)
            except NotConnected:
                pass
            except Exception:  # pylint: disable=broad-except
                self.logger.exception("[%s:%s] Exception",
                                      self.fn or self.host, self.port)

            self._open_channels.remove(destination_id)

            self.handle_channel_disconnected()
1330933
function Session_delChannel(channel) {
  var index = this.channels.indexOf(channel)
  if (-1 == index) return

  this.channels.splice(index, 1)
}
177724
def handle_part(self, params):
        
        for pchannel in params.split(','):
            if pchannel.strip() in self.server.channels:
                # Send message to all clients in all channels user is in, and
                # remove the user from the channels.
                channel = self.server.channels.get(pchannel.strip())
                response = ':%s PART :%s' % (self.client_ident(), pchannel)
                if channel:
                    for client in channel.clients:
                        client.send_queue.append(response)
                channel.clients.remove(self)
                self.channels.pop(pchannel)
            else:
                _vars = self.server.servername, pchannel, pchannel
                response = ':%s 403 %s :%s' % _vars
                self.send_queue.append(response)
162230
def ban_member_from_group(self, group_jid, peer_jid):
        
        log.info("[+] Requesting ban of user {} from group {}".format(peer_jid, group_jid))
        return self._send_xmpp_element(group_adminship.BanMemberRequest(group_jid, peer_jid))
1295512
def onExit(self):
        
        def try_call(fn):
            try:
                fn()
            except (pika.exceptions.ChannelClosed, AttributeError,
                    pika.exceptions.ConnectionClosed):
                return

        if hasattr(self, "channel"):
            try_call(self.channel.cancel)
            try_call(self.channel.close)
            try_call(self.connection.close)
1033553
def send_private_message(self, user_id, message):
        
        try:
            client = self.channels['private'][str(user_id)]
        except KeyError:
            print '====debug===='
            print self.channels['private']
            print 'client with id %s not found' % user_id
            return False
        
        client.send_message(message)
        print 'message sent to client #%s' % user_id
        return True
642175
def logout_user(f):
    

    @functools.wraps(f)
    def deco(*a, **kw):
        signals.user_logout(lambda: flask_login.current_user)
        flask_login.logout_user()
        return f(*a, **kw)

    return deco
1183449
def invite(self, channel, nick):
        
        with self.lock:
            self.is_in_channel(channel)

            self.send('INVITE %s %s' % (nick, channel))

            while self.readable():
                    msg = self._recv(expected_replies=('341', '301'))

                    if msg[0] == '341':
                        pass
                    elif msg[0] == '301':
                        away_msg = msg[2].split()[1].replace(':', '', 1)
                        return 'AWAY', away_msg
913803
def cmd(send, msg, args):
    
    c, nick = args['handler'].connection, args['nick']
    channel = args['target'] if args['target'] != 'private' else args['config']['core']['channel']
    if not msg:
        send("Nuke who?")
        return
    with args['handler'].data_lock:
        users = args['handler'].channels[channel].users()
    if msg in users:
        do_nuke(c, nick, msg, channel)
    elif msg == args['botnick']:
        send("Sorry, Self-Nuking is disabled pending aquisition of a Lead-Lined Fridge.")
    else:
        send("I'm sorry. Anonymous Nuking is not allowed")
738712
def chat_delete(self, *, channel: str, ts: str, **kwargs) -> SlackResponse:
        
        kwargs.update({"channel": channel, "ts": ts})
        return self.api_call("chat.delete", json=kwargs)
966930
async def unban(self, channel, target, range=0):
        
        if target in self.users:
            host = self.users[target]['hostname']
        else:
            host = target

        host = self._format_host_range(host, range)
        mask = self._format_host_mask('*', '*', host)
        await self.rawmsg('MODE', channel, '-b', mask)
768002
def delete(self, user, name):
        

        uri = self.client.remote + '/users/{}/feeds/{}'.format(user, name)

        resp = self.client.session.delete(uri)
        return resp.status_code